PDA

View Full Version : Ext.data.DirectStore: root property issues



AndreaCammarata
14 Jul 2009, 4:43 AM
Hi all,
I'm trying to write down a simple piece of code to learn how to use a Ext.data.DirectStore, but I don't figure out what's going on.
I explain better my problem:
What i want to do is really simple, i want to populate a GridPanel using a directFn.
I wrote and included in my test page a .ashx that returns me the remoting api as follow



Ext.app.REMOTING_API = {"type":"remoting","url":"/TestHandler.ashx","namespace":"MyApp","actions":{"Test":[{"name":"getAll","len":0}]}};


and after that i wrote down the source code of my test page



var store = new Ext.data.DirectStore({
storeId: 'fileStore',
autoLoad: true,
directFn: MyApp.Test.getAll,
paramsAsHash: false,
totalProperty: 'count',
root: 'testData',
fields: [
{name:'name', type: 'string'}
],
listeners: {
dataChanged: function(store){
Ext.Msg.alert('Store Load','The Data has been loaded!');
}}
});

var gp = new Ext.grid.GridPanel({
id: 'gp',
store: store,
renderTo: Ext.getBody(),
height: 300,
columns: [
{id: 'name', header: 'Name', sortable: true, dataIndex: 'name'}
],
sm: new Ext.grid.RowSelectionModel({

})
});
});


Now inspecting the execution with FireBug, I see the following response coming form the TestHandler.ashx



{"type":"rpc","tid":2,"action":"Test","method":"getAll","result":"{count:11,'testData':[{\"name\":\"kids_hug.jpg\"},{\"name\":\"kids_hug2.jpg\"},{\"name\":\"sara_pink.jpg\"},{\"name\":\"sara_pumpkin.jpg\"},{\"name\":\"sara_smile.jpg\"},{\"name\":\"up_to_something.jpg\"},{\"name\":\"zack.jpg\"},{\"name\":\"zacks_grill.jpg\"},{\"name\":\"zack_dress.jpg\"},{\"name\":\"zack_hat.jpg\"},{\"name\":\"zack_sink.jpg\"}]}","message":null}


This is Ok beacuse it means that the DirectHandler is called correctly and i'ma ble to retrive the data I need, but the problem is that the grid doesn't populate at all.
Note: If i change the DirectStore root property as follow



root: ''


the grid will be populated with a LOT of empty records and the 'Name' column doesn't contain any value.
Does anyone knows what i'm missing?
I read a lot of post and everyone solved with the config



paramsAsHash: false


but it doesn't seems to be my case.
Thanks a lot!

AndreaCammarata
16 Jul 2009, 9:59 AM
Does Anyone has a solution for this issue?
Any help / suggest would be appreciated.
Thanks!

evant
16 Jul 2009, 10:11 AM
Get the latest version of the router.

AndreaCammarata
20 Jul 2009, 7:59 AM
Hi Evant,
i follow your suggest and i download the latest version of your router, you posted today at http://www.extjs.com/forum/showthread.php?t=68161, but it doesn't work too with my example, so i suppose it's a bug.
I'm no moving forward so i'm planning to continue using my classic version of ux.FileView without integrating the new Ext.Direct development API.
I post a screen of my "new born" ux.FileView.
It comes with the full locale support to translate it in every language you want and fully customizable file icons using a single sprite.
I will make a new post in the appropriate "User Extenctions" forum section when i'm done!
If someone can help me about using Ext.Direct API i will appreciate it!
Thanks to everybody!