PDA

View Full Version : Simple Grid does not get filled with data..



noncom
4 Feb 2013, 4:26 AM
I have the following code on my page. The grid is displayed ok with the names of the columns, but the data is missing. The real records amount is truncated not to waste the space on this forum:



<script type="text/javascript">


Ext.onReady(function() {


Ext.state.Manager.setProvider(Ext.create('Ext.state.CookieProvider'));


Ext.define('model_grid', {
extend: 'Ext.data.Model',
fields: [
{
convert: null,
defaultValue: undefined
},{
type: 'string',
convert: null,
defaultValue: undefined
},{
type: 'string',
convert: null,
defaultValue: undefined
},{
type: 'string',
convert: null,
defaultValue: undefined
},{
type: 'bool',
convert: null,
defaultValue: undefined
}
]
});


var data_grid = [
['John', 'id-AA1', 'worker', 'super departament', true],
['Bob', 'id-CCA', 'sub-worker', 'departament of kki', true],
['Smith', 'id-AA2, 'manager', 'departament of kki', false]
];


var store = Ext.create('Ext.data.ArrayStore', {
data: data_grid,
model: 'model_grid'
});


/*
* ========== comment ==========
*/


var var_grid = Ext.widget({
columns: [
{
text: 'Name',
sortable: true,
flex: 1,
dataIndex: 'name',
width: 200
},{
text: 'Card',
sortable: false,
width: 75
},{
text: 'Position',
sortable: true,
dataIndex: 'position',
width: 100
},{
text: 'Departament',
sortable: true,
dataIndex: 'pctChange',
width: 100
},{
text: 'Employed',
sortable: false,
width: 50
}
],
store: store,
name: 'grid',
xtype: 'gridpanel'
});


var_grid.render(document.body);
});


</script>

Why does not data go into the table?

ateodorescu
4 Feb 2013, 5:17 AM
Hi,

You used "dataIndex" on your column definitions but your model fields have no "name". Remove "convert" configs and add names.

Cheers

noncom
4 Feb 2013, 5:51 AM
Thank you so much! That worked!!!