Reputation: 3038
Here is my code:
function getStore (json) {
var reader = new Ext.data.JsonReader({
root : 'data',
successProperty: 'success',
totalProperty: "rows",
fields : [
{name: 'num', allowBlank:'true'},
{name: 'date', dateFormat:'d.m.Y H:i:s', type: 'date'},
{name: 'signerFIO', type: 'string'},
{name: 'checkSign', type: 'boolean'}
]
});
var store = new Ext.data.JsonStore ({
data : json,
reader : reader
});
return store;
}
The data arrived from the server is: {"data":[{"num":"111","signerFIO":"hello","checkSign":true,"date":"25.05.2012"}],"success":1,"rows":1}
I've tried to set a 'json' function parameter to a raw json (as it arrived) and to a Ext.util.JSON.decode(response.responseText)
I've tried this code in the FF and in the FireBug I've got the strange h is undefined
error.
Does anybody know what is wrong?
UPDATE
This
var store = new Ext.data.JsonStore ({
data : json,
fields : ['data']
});
worked for me in terms that there was no errors, but no data was loaded either.
Upvotes: 0
Views: 2754
Reputation: 3038
The problem was in the reader (actually, I don't know what a problem). This:
function getStore (jsonRequestUrl) {
var store = new Ext.data.JsonStore ({
autoLoad : false,
proxy : new Ext.data.HttpProxy({ url: jsonRequestUrl, method: 'POST' }),
root : 'data',
successProperty : 'success',
totalProperty : "rows",
idProperty : "id",
fields : [
{name: 'num', type: 'string', mapping: 'num'},
{name: 'signerFIO', type: 'string', mapping: 'signerFIO'},
{name: 'checkSign', type: 'boolean', mapping: 'checkSign'},
{name: 'date', dateFormat:'d.m.Y', type: 'date', mapping: 'date'}
]
});
store.load();
return store;
}
worked for me.
Upvotes: 0
Reputation: 5712
I'm really not sure what you're trying to do with this code, but this will make it work (assuming json is a decoded object and not a string):
Ext.define("MyItem", {
extend: "Ext.data.Model",
fields: [
{name: 'num', allowBlank:'true'},
{name: 'date', dateFormat:'d.m.Y H:i:s', type: 'date'},
{name: 'signerFIO', type: 'string'},
{name: 'checkSign', type: 'boolean'}
]
});
function getStore (json) {
var store = new Ext.data.JsonStore ({
data: json.data,
model: MyItem
});
return store;
}
Upvotes: 1