PDA

View Full Version : Combobox with checkbox selection



jack sparrow
18 Jul 2009, 9:12 AM
Hi all....maybe my post title is not very clean: an example is here (http://www.tonylandis.com/code-projects/ext-multiselect-combobox-extension.htm)

I'm interested to first example!!

I'm going to be crazy: I would like to populate my "State Combobox" with data from a database.

This is my json encoded database output :


({"total":"5","results":[ {"id":"DE","name":"Delaware"}, {"id":"DC","name":"District of Columbia"}, {"id":"FL","name":"Florida"}, {"id":"GA","name":"Georgia"}, {"id":"HI","name":"Hawaii"} ]})


This is my example-grid-multiselect.js file, which create the " dynamic store"


Ext.namespace('Ext.example');

// I commented "static store"
/*Ext.namespace('Ext.exampledata');

Ext.exampledata.states = [
['AL', 'Alabama', 'The Heart of Dixie'],
['AK', 'Alaska', 'The Land of the Midnight Sun'],
['AZ', 'Arizona', 'The Grand Canyon State'],
['AR', 'Arkansas', 'The Natural State'],
['CA', 'California', 'The Golden State'],
['CO', 'Colorado', 'The Mountain State'],
['CT', 'Connecticut', 'The Constitution State'],
['DE', 'Delaware', 'The First State'],
['DC', 'District of Columbia', "The Nation's Capital"],
['FL', 'Florida', 'The Sunshine State'],
['GA', 'Georgia', 'The Peach State'],
['HI', 'Hawaii', 'The Aloha State']
];
Ext.example.Store = new Ext.data.SimpleStore({
fields: ['id', 'name', 'title'],
data : Ext.exampledata.states
});*/


//Here start my "dinamyc store"
Ext.example.Store = new Ext.data.Store({
id: 'StatesData',
proxy: new Ext.data.HttpProxy({
url: 'database.php',
method: 'POST'
}),
reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total'
},[
{name: 'id', type: 'string', mapping: 'id'},
{name: 'name', type: 'string', mapping: 'name'}
]),
sortInfo:{field: 'name', direction: "ASC"}
});

Ext.example.Store.load();


I don't know why...but "my dynamic" store doesn't work...and the combobox is empty!!

I hope someone could help me. I use Ext 2.2!!

Attached to this post a zip of my script...with essential files needed to "work"!

Tnx in advance