Colin
Colin

Reputation: 1855

ExtJS: dataIndex property not working

My Simplified Store:

Ext.define('PT.store.DealTree', {
    extend: 'Ext.data.TreeStore',
    proxy: {
        type: 'rest',
        url:  '/dealTree',
        reader: { type: 'json', root: 'children', successProperty: 'success' },
    },
    root: { name: 'children', expanded: true }
})

My Simplified Grid:

Ext.define('PT.view.deal.DealSelectionGrid', {
    extend: 'Ext.tree.Panel',
    alias: 'widget.dealSelectionGrid',
    rootVisible: false,
    fields: ['text', 'date'],

    store: 'DealTree',
    columns: [
        { xtype: 'treecolumn', text: 'Deal', dataIndex: 'text' },
        { xtype: 'datecolumn', text: 'Date', dataIndex: 'date' }
    ]   
});

Example of simplified response:

[ { text: 'aNode',
    id: 522f7dd2323544c424000034,
    leaf: true,
    date: '2013/10/10' } ]

nothing appears in the Date column, yet the text, leaf, id all work perfectly. I'm clearly missing something. Currently, I'm not using a model because each level is a different model, which isn't supported by default - hence I let ExtJS add all the NodeInterface decoration for me.

Upvotes: 0

Views: 756

Answers (1)

rixo
rixo

Reputation: 25041

The fields configuration goes into the store, not the tree component.

For example, your code is showing the date with this store:

Ext.define('PT.store.DealTree', {
    extend: 'Ext.data.TreeStore',
    proxy: {
        type: 'rest',
        url:  '/dealTree',
        reader: { type: 'json', root: 'children', successProperty: 'success' }
    },

    // fields option here!
    fields: ['text', 'date'],

    root: {
        name: 'children',
        expanded: true,
        children: [{
            text: 'aNode',
            id: '522f7dd2323544c424000034',
            leaf: true,
            date: '2013/10/10'
        }]
    }
});

Upvotes: 2

Related Questions