PDA

View Full Version : DirectStore and ComboBox



wmazza
15 Sep 2009, 4:25 PM
Hey all,

I cannot seem to get DirectStore to work properly with my ComboBox! :((

So here is my code (obviously leaving out everything unrelated to the combox and store :P)



var store = new Ext.data.DirectStore({
directFn: MyApiFunc.getDates,
fields: [{
name: 'date'
}]
});

var cb = new Ext.form.ComboBox({
store: store,
displayField: 'date',
typeAhead: true,
triggerAction: 'all',
mode: 'remote',
emptyText: 'Select a date...'
});
And here is the response I get from the server



{"type":"rpc","tid":2,"action":"MyApiFunc","method":"getDates","result":["2009-08-29","2009-09-05"]}


Basically, when I click the drop-down box for the combo-box, i see in firebug that it makes the request. But the combobox keeps showing the "Loading" message/spinner and if I inspect the store itself, the store.data.items array is empty!

do I have to change the way I have the data returned (the "result" field) or do I have to create a callback (Ext.Direct.on('event'....))?

Any help would be appreciated. :)

evant
15 Sep 2009, 8:12 PM
You have no reader on your store.

wmazza
16 Sep 2009, 8:14 AM
evant -

Thanks for pointing that out. :) i went ahead and added the root, totalProperty, idProperty, and successProperty to the store, and as well as ensure that information is also returned from the server.

However, I found out that even after setting up that information, it still did not populate... :(

After some further Googling, I found this thread: https://extjs.net/forum/showthread.php?p=386642

Apparently, I have to make sure that the len property is 1 in order for it to read the data? Kinda strange imo, but I simplified that just adding a dummy variable to my php script :P



class MyApiFunc
{
public function getDates($dummyData="")
...
}

is there a reason for this?

Edit: the combobox is working now just fyi :)