Вопрос

I receive an array of strings from the server. How can I populate my grid panel if the data is not in key-value format?

Here is the response:

{"result":true,"data":["dep1","dep2","dep3"],"totalCount":3}

Here is my grid panel

xtype: 'gridpanel',
flex: 1,
itemId: 'departmentsGridPanel',
title: '',
store: new Ext.data.ArrayStore({
    autoLoad: true,
    fields: [
        'department'
    ],
    proxy: {
        type: 'ajax',
        url: 'FilteringDataServlet?filterColumn=avdeling',
        reader: {
            type: 'json',
            root: 'data'
        }
    }
}),
columns: [{
    text: 'Avdeling',
    flex: 1,
    dataIndex: 'department'
}],
Это было полезно?

Решение 2

I have solved this by adding load listener to my store and modifying the data there

listeners: { 
  load: function(store, records, success, opts) { 
           store.each(function(record) { 
              record.set('department', record.raw); 
           }); 
         } 
}

Другие советы

Then you should use Ext.data.reader.Array with mapping parameter.

Employee = Ext.define('Employee', {
extend: 'Ext.data.Model',
fields: [
    {name: 'name', mapping: 0},         // "mapping" only needed if an "id" field is present which
    {name: 'occupation', mapping: 1}    // precludes using the ordinal position as the index.        
]
});
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top