View Full Version : Ext.Direct Combo

5 Jun 2009, 8:12 AM
Hello, I have been trying to get this working for a while now with no joy. I am using the Ext Direct pack for .NET and have a simple test case set up.

I have a combo configured like so:

DB.Controls.ClientDropDown = Ext.extend(Ext.form.ComboBox, {

// If or not we want active only
activeOnly: true,

// Initialize Component Override
initComponent: function() {
Ext.apply(this, {
typeAhead: true,
triggerAction: 'all',
forceSelection: true,
loadingText: 'Loading Client List...',
shadow: false,
displayField: 'Name',
valueField: 'ClientNumber',
selectOnFocus: true,
emptyText: 'Choose a Client',
allowBlank: false,
editable: true,
minChars: 2,
enableKeyEvents: true,
minListWidth: 270,
listeners: {
'keypress': {
buffer: 100,
fn: function() {
if (!this.getRawValue()) {
this.doQuery('', true);
tpl: new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item">[{ClientNumber}] {Name}</div></tpl>'),
store: new Ext.data.DirectStore({
paramsAsHash: false,
idProperty: 'ClientNumber',
root: 'clients',
directFn: Clients.GetClients,
fields: ['CompanyNumber', 'ClientNumber', 'Name', 'IsActive', 'ActiveEmployees'],
paramOrder: ['activeOnly'],
baseParams: {
activeOnly: this.activeOnly
listeners: {
'exception': {
fn: function(sender, type, action, options, response, error) {

// Parent Constructor
DB.Controls.ClientDropDown.superclass.initComponent.apply(this, arguments);
Ext.reg('clientdropdown', DB.Controls.ClientDropDown);

The call to the Direct Method returns the following:

"type": "rpc",
"tid": 2,
"action": "Clients",
"method": "GetClients",
"result": "{\"clients\":[{\"ClientNumber\":7936,\"CompanyNumber\":1,\"Name\":\"A Client\",\"IsActive\":true,\"ActiveEmployees\":0}]}"

Which when run through the JSONLint site returns saying it is valid.

I am getting a 'root is not defined' error logged in the firebug console even though I have defined it. What am I missing?? Thank you for your help.

5 Jun 2009, 10:15 AM
Your 'result' is double encoded. Try returning a plain old object instead of a serializing the object to JSON. The result is being sent to the Ext.data.Store as a string rather than an object.