PDA

View Full Version : EditorGrid: How can I distinguish between CRUD in DirectStores?



Dumas
14 Dec 2009, 8:03 PM
Hey Guys!

I couldn't find something on the web, so here's my question.
How can I use an DirectStore with an Editorgrid?

I defined the store with these properties

proxy: new Ext.data.DirectProxy({
directFn : AppDirect.Tasks
}),
writer: writer = new Ext.data.JsonWriter({
encode: false // Ext.Direct needs that
})

But when I e.g. delete a row it only sends data arrays like [10]. So there is no way on the server to know what it is :-/

Is there a way for Ext.direct to split into crud request like you can do with normal requests in the api config property?

thx
Dumas

sancho_0
15 Dec 2009, 7:33 AM
Hi there,

this works for me:


var reader = new Ext.data.JsonReader({
totalProperty: 'total',
successProperty: 'success',
idProperty: 'id',
root: 'records'
}, [
{name: 'id'},
...
]);


var writer = new Ext.data.JsonWriter({
encode: false,
writeAllFields: false
});

var store = new Ext.data.DirectStore({
api: {
create: AppDirect.Tasks.create,
read: AppDirect.Tasks.read,
update: AppDirect.Tasks.update,
destroy: AppDirect.Tasks.destroy
},
reader: reader,
writer: writer,
autoSave: true
});

store.load();That way, when you delete a row, ExtJS will call to AppDirect.Tasks.destroy, and that function should know what to do with a single or list of id's.

But I found some issues, that I still don't know if there are bugs or what... (nobody replied yet) You may want to take look to this thread:

http://www.extjs.com/forum/showthread.php?t=83777

Hope it helps.

Best Regards

Dumas
18 Dec 2009, 2:51 PM
thx, works :-)