PDA

View Full Version : Ext.DirectStore



ck4ExtJS
17 Jun 2010, 2:42 AM
Hi,

i am having problems with a direct store.


var grid = new Ext.grid.GridPanel({
store: new Ext.data.DirectStore({
directFn:Data_Contacts.read,
autoLoad: true,
autoDestroy: true,
listeners:{
exception:{
fn: function(proxy, type, action, options, response, arg){
alert(type + ' ' + arg);
}
},
metachange:{
fn: function(store, meta){
alert(meta);
}
}
}
}),
colModel: new Ext.grid.ColumnModel({
columns:[{
dataIndex:'lastname',
header: 'last name',
id: 'lnCol'
},{
dataIndex:'firstname',
header: 'first name',
id: 'fnCol'
}]
})
});

var wnd = new Ext.Window({
width: 600,
height: 400,
border: false,
layout:'fit',
items:[grid]
});
wnd.show();

My Method returnes the following from serverside:


{"type":"rpc","action":"Data_Contacts","method":"read","result":{
metadata: {
fields: [
{
name: "id",
type: "int"
},
{name: "firstname"},
{name: "lastname"}
],
idProperty: "id",
limit: 2,
root: "rows",
sortInfo: {
direction: "ASC",
field: "lastname"
},
start: 0,
successProperty: "success",
totalProperty: "results"
},
results: 2000,
rows: [
{
firstname: "Klaus",
id: 1,
lastname: "Schneider"
},
{
firstname: "Peter",
id: 2,
lastname: "Damenbart"
}
],
success: true
},"tid":2}

But i always get an response exception 'TypeError: trans.reader is undefined'.

Thanks for help...

evant
17 Jun 2010, 2:54 AM
Exactly what it says. You need a reader on your store.

ck4ExtJS
17 Jun 2010, 2:58 AM
Ok,

but isnt't the DirectStore configured with a JsonReader per default?

ck4ExtJS
17 Jun 2010, 3:41 AM
Got it working by adding reader: new Ext.data.JsonReader() to DirectStore config -- thanks evant