0

グリッドを表示しようとしています。このソートでは機能していません。これが私のコードです。

    <div id="grid-sample"></div>
    <script type="text/javascript">
        Ext.create('Ext.data.Store', {
            storeId:'cstore',
            fields:['user', 'age', 'place'],
            data: [
                        {"user":"joe","age":27,"place":"sydney"},
                        {"user":"abel","age":29,"place":"delhi"},
                        {"user":"fin","age":18,"place":"san jose"}
                    ]

        });

        Ext.create('Ext.grid.Panel', {
            title: 'Sample grid',
            store: Ext.data.StoreManager.lookup('cstore'),
            autoCreateViewPort: false,
            layout: 'fit',
            columns: [
                { text: 'Name', xtype: 'templatecolumn', tpl: '{user}' ,sortable : true },
                { text: 'Age', xtype: 'templatecolumn', tpl: '{age}' ,sortable : true },
                { text: 'Place', xtype: 'templatecolumn', tpl: '{place}',sortable : true  }
            ],
            width: 750,
            renderTo: 'grid-sample'
        });
    </script>
4

2 に答える 2

1

dataIndex がフィールドではなくオブジェクトのプロパティを参照する必要がある場合はどうなるでしょうか? したがって、上記のデータは次のようになります

data: [{{"user":"joe",userName:"Joeschmoe"},"age":27,"place":"sydney"},
{{"user":"Jane",userName:"Jany"},"age":29,"place":"delhi"},
{{"user":"Mary",userName:"mary123"},"age":18,"place":"san jose"}
]
于 2015-07-28T14:57:48.873 に答える