View Full Version : Editor Grid: Store successfully loaded but not the grid

10 May 2010, 11:01 PM
Any idea, why Grid is NOT populated, when store is successfully loaded. I try do the reload but no effect. I suspect there something missing in this code.

The store

_jsremoteSmResDetail = new Ext.data.JsonStore({
autoLoad: true,
id: 'remoteSmResDetail',
writer: new Ext.data.JsonWriter(),
proxy: new Ext.data.HttpProxy({
method: 'POST',
url: 'app/php/smResultDetail.php'
reader: new Ext.data.JsonReader({
root: "data" ,
totalProperty: 'total',
id: ['dt_id', 'dt_loc3', 'dt_subject', 'dt_semester', 'dt_section'],
fields: ['dt_id', 'dt_loc3', 'dt_subject', 'dt_semester', 'dt_section', 'dt_desc_02', 'dt_cp', 'dt_point']

The column

var smrtFields = [
{name: 'dt_id', dataIndex: 'dt_id',hidden: true},
{name: 'dt_loc3', dataIndex: 'dt_loc3',hidden: true},
{header: "Subject ID", id: 'dt_subject' , name: 'dt_subject', width: 50, sortable: true,
dataIndex: 'dt_subject', editor: new Ext.form.TextField({})},
{name: 'dt_semester', dataIndex: 'dt_semester',hidden: true},
{header: "Section",name: 'dt_section', width: 10, sortable: true, dataIndex: 'dt_section',
editor: new Ext.form.TextField({})},
{header: "Description",name: 'dt_desc_02', width: 130, sortable: true, dataIndex:
'dt_desc_02', editor: new Ext.form.TextField({})},
{header: "Point",name: 'dt_cp', width: 40, sortable: true, dataIndex: 'dt_cp', editor: new
{header: "CR Hour",name: 'dt_point', width: 40, sortable: true, dataIndex: 'dt_point',
editor: new Ext.form.NumberField({})}

var cm = new Ext.grid.ColumnModel([smrtFields]);

The Grid

var userGrid = new Ext.grid.GridPanel({
iconCls: 'icon-grid',
frame: true,
autoScroll: true,
height: 300,
//data: onRetrieve,
store: _jsremoteSmResDetail,
plugins: [editor],
columns : smrtFields,
selModel: new Ext.grid.RowSelectionModel({singleSelect:false}),
//colModel: cm,
tbar: [{
text: 'Add New Subject',
iconCls: 'icon-new',
handler: onAdd
}, '-',{
text: 'List Registerred Subject',
iconCls: 'icon-cog',
handler: onRetrieve
}, '-',{
text: 'Print Subject List',
iconCls: 'icon-print',
handler: basic_printGrid
}, '->', {
text: 'Exit',
iconCls: 'icon-home',
handler: function() {_subjWindow.hide();}
viewConfig: {
forceFit: true

function onRetrieve() {
params: {id: Ext.getCmp('sr_id').getValue(), sm: userSemester}

The result show in firebug

{success: true,"total":3, "data":

Thanks in advance


11 May 2010, 7:34 AM
You just might want to use Ext.data.Store instead of Ext.data.JsonStore. You already specify the JsonReader and JsonWriter within it. Don't know if this would solve the problem.

11 May 2010, 8:38 AM
Looks like you are double wrapping your ColumnModel to me which may be an issue. (There is an array in smrtFields and then also an array when you create the ColumnModel)

Do you receive any errors?

11 May 2010, 7:14 PM
Hi both of u

CrazyEnigma: yr opinion dosn't have impact. I have tried using Ext.data.Store, fyi. reason i use JsonWriter b'cos with that system will carry 'xaction' parameter.

aconran: correct ColumnModel is an array, I double wraping it but i don't use it, see I comment the 'colModel: cm'

My Objective.

I want to read a dynamic data (from mySQL), populate it in a grid. then allow user to edit/manipulate it, then allow them to save back the data to database.

Very much thanks again to everyone...

11 May 2010, 10:05 PM
Yes, I didn't know if that would have solved your problem as I have stated, but if you are planning to use Pagination in the future, then you are going to have to switch out JsonStore for Store. JsonStore is an extended object of Store, but for some reason, Pagination only accepts Store. You can still have readers and writers that are of the Json flavour.

Anyways, now is the time to start making a smaller data table and seeing if you can perform edits on a one attribute table and see where your problem might be.

Your reader doesn't seem to be set up properly, or is it just me. You have number fields, that you might want to set in your fields. And I don't understand your id property in your reader. It doesn't look standard. Are you trying to set the "idProperty" property?

12 May 2010, 4:58 AM
When you use JsonStore you cannot pass in a reader, just the config options for the reader; take a look at the config options and examples in JsonStore API (http://www.extjs.com/deploy/dev/docs/?class=Ext.data.JsonStore). If you were to look at the source code for JsonStore you would see that it creates a new JsonReader using the config options passed in and does not look to see if you passed in a reader.

The way your store is configured, you could use Ext.data.Store. I recommend that. Did you try that? Your response to CrazyEnigma was hard for me to understand, CE did not say not to use JsonWriter. You probably have more than one problem in your code.

Not sure what this is trying to do, JsonReader now takes an idProperty, not an "id". Can you define the id with multiple properties? I've never seen that.:

id: ['dt_id', 'dt_loc3', 'dt_subject', 'dt_semester', 'dt_section'],

What do you mean by the store is successfully loaded? Are you sure? Did you try adding load and exception handlers and in the load handler examining the records in the store?

12 May 2010, 10:57 PM
Hi everybody

thanks to everyone when i change to 'idproperty' everything is ok now. wondering what does 'idproperty' mean to the Json Reader?. can anybody explain a bit. in my understand may be is a just combination key (ie. the key that is combining a few fields in atable), or maybe its wrong!.

Anyway thanks very much to everybody helping!.

13 May 2010, 1:32 AM
idProperty : String
[id] Name of the property within a row object that contains a record identifier value. Defaults to id

it has to be unique and it has to be one field.
it is not yet possible to create keys with combining fields, like you can do with dbs.

@enigma: paging is possible with json-stores.

kind regards,