PDA

View Full Version : populating grid



kirankumar1231
29 Mar 2011, 1:28 AM
hello experts

this is my json structure

{"total":3,"data":[{"empid":1231,"empname":"kiran kumar"},{"empid":1232,"empname":"kiran"},{"empid":1233,"empname":"kumar"}]}

values are not getting populated into my grid

this is my code



<script type="text/javascript">
Ext.onReady(function() {
Ext.QuickTips.init();
var reader=new Ext.data.JsonReader({
root: "data",
totalProperty: "total",
feilds:[
{name: 'empid',mapping:'empid'},
{name: 'empname',mapping:'empname'}
]
});
var store=new Ext.data.Store({
remoteSort:true,
proxy : new Ext.data.HttpProxy({
url: 'get.json',
method:'GET'
}),
reader:reader
});
var colModel = new Ext.grid.ColumnModel([
{header: "empid", width: 120, sortable: true, dataIndex: "empid"},
{header: "empname", width: 90, sortable: true, dataIndex: "empname"}
]);


var grid = new Ext.grid.GridPanel({ height:200,
title:'employee details',
width:600,
store:store,
cm: colModel,

remoteSort:true,
listeners:{
keyup:function(e1){
alert("clicked me");
var a=e1.getType();
alert(a);
}
}
});
store.load();
grid.render(document.body);
});
</script>


when the json structure is some thing like this
[{"empid":1231,"empname":"kiran kumar"},{"empid":1232,"empname":"kiran"},{"empid":1233,"empname":"kumar"}]
values are loaded to my grid

tvanzoelen
29 Mar 2011, 1:44 AM
did you mistype fields?



feilds:[
{name: 'empid',mapping:'empid'},
{name: 'empname',mapping:'empname'}
]

kirankumar1231
29 Mar 2011, 2:02 AM
no i have given correct fields

tvanzoelen
29 Mar 2011, 2:04 AM
in the code you posted fields is spelled like feilds

take a look at that property in the reader


feilds:[
{name: 'empid',mapping:'empid'},
{name: 'empname',mapping:'empname'}
]

kirankumar1231
29 Mar 2011, 2:08 AM
very sorry yaar thank you very much