PDA

View Full Version : how to dsiplay the static json data with editor grid



barbara1712
15 Jan 2010, 3:51 AM
Hi All,

I want to display the static json in the editor grid.
But Its not working on IE getting error
On FF, It is displaying the blank grid

The code is as




KRAWReader = new Ext.data.JsonReader({
idProperty: 'kra_id',
fields: [
{name: 'kra_id',mapping:'kra_id', type: 'int'},
{name: 'weightage',mapping:'weightage', type: 'int'},
{name: 'name',mapping:'name'},
{name: 'flag',mapping:'flag', type: 'int'}
]
});

KRAWeightageStore = new Ext.data.Store({
reader:KRAWReader
});

KRAWeightageStore.loadData(finalJson);

// create the editor grid
KRAWeightageGrid = new Ext.grid.EditorGridPanel({
store: KRAWeightageStore,
title: 'Set KRA Weightage',
autoScroll:true,
frame: true,
clicksToEdit: 1,
columns:
[
{id: 'kra_id',header: "",dataIndex: 'kra_id',hidden:true},
{id: 'name',header: "KRA Name",dataIndex: 'name',sortable: true,width:300},
{id: 'weightage',header: "Weightage",dataIndex: 'weightage',width:100}
],
viewConfig: {
forceFit:true,
enableRowBody:true,
emptyText: '<b><center>No records to display</b></center>'
}
});

dispKRAWeightageWin = new Ext.Window({
modal:true,
layout:'fit',
width:500,
height:400,
closable:true,
resizable:true,
plain:true,
items:[KRAWeightageGrid]
});
dispKRAWeightageWin.show();




And my json data (finalJson) is

[[3,3,"Accountability",1],[2,4,"Timliness of Delivery",1],[5,4,"Processes",1]]

Please help me.
Your help will be highly appriciated.

Thanks

Condor
15 Jan 2010, 4:27 AM
Your JSON data doesn't match your reader.

You want:

KRAWReader = new Ext.data.ArrayReader({
idIndex: 0,
fields: [
{name: 'kra_id', type: 'int'},
{name: 'weightage', type: 'int'},
{name: 'name'},
{name: 'flag', type: 'int'}
]
});

barbara1712
15 Jan 2010, 4:40 AM
Thanks

I have tried with the above reader,
But on FF
I am getting blank grid

and on IE, I am getting the following error

Message: 'undefined' is null or not an object
Line: 7
Char: 286364
Code: 0
URI: http://localhost/mydemo/ext-3.0.0/ext-all.js (http://localhost/mydemo/ext-3.0.0/ext-all.js)

Actually,
I want to have a Editable grid and grouping store.
But first I just want to try with editable grid

please help me.

Condor
15 Jan 2010, 4:57 AM
After making the change I suggested I get a perfectly good grid with data on both IE and FF.

ps. If you actually want your fields to be editable then you need to define editors in for your columns.

barbara1712
15 Jan 2010, 5:29 AM
Yes you are right,

Thanks a lot Condor.

I cleared the catch and worked fine.
Now trying for grouping.

But getting 'h is undefined' error in FF