PDA

View Full Version : chain mode



alien3d
6 Nov 2009, 5:11 AM
The coding below work but if the user choose the second combobox first rather then first combobox.Extjs will give error. Can extjs make null store?:-/


this.store is undefined




departmentId.on('select', function() {
// recall back the store
var department_loc_store = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({
url : 'arnab.php'
}),
reader : department_loc_reader,
remoteSort : false,
baseParams : {method:'read',mode:'chained',departmentId:departmentId.getValue() }
});
department_locId.store=department_loc_store; //reference back store
department_loc_store.load();
});

// map to array first so can reload when department is choosen,testingo
var department_loc_reader = new Ext.data.JsonReader({ root:'data' }, [ 'value', 'text']);

// store will be remote
var department_locId = new Ext.ux.form.ComboBoxMatch({
//store :'',
minChars : 0,
valueField : 'value',
displayField : 'text',
xtype : 'combo',
labelAlign : 'left',
fieldLabel : 'Location ',
hiddenName : 'department_locId',
anchor : '95%',
emptyText : 'Please Select location',
typeAhead : false,
triggerAction : 'all'
});

Animal
6 Nov 2009, 6:09 AM
Configure department_locId with a Store. It's not an optional config.

alien3d
6 Nov 2009, 7:11 AM
If i configure with dummy store department_locId.When user choose combobox first,the ajax will reload the store but when user click the second combobox.It will reload back with the dummy store.If configure directly,it will count the store and error will appear.The last choice for temporary purpose i put disable first the second combobox.To prevent the user click the second box first./:)


departmentId.on('select', function() {
// recall back the store
department_locId.enable();
var department_loc_store = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({
url : 'arnab.php'
}),
reader : department_loc_reader,
remoteSort : false,
baseParams : {method:'read',mode:'chained',departmentId:departmentId.getValue() }
});
department_locId.store=department_loc_store; //reference back store
department_loc_store.load();
});

// map to array first so can reload when department is choosen,testingo
var department_loc_reader = new Ext.data.JsonReader({ root:'data' }, [ 'value', 'text']);

// store will be remote
var department_locId = new Ext.ux.form.ComboBoxMatch({
store :'',
minChars : 0,
valueField : 'value',
displayField : 'text',
xtype : 'combo',
labelAlign : 'left',
fieldLabel : 'Location ',
hiddenName : 'department_locId',
anchor : '95%',
emptyText : 'Please Select location',
typeAhead : false,
triggerAction : 'all',

});
department_locId.disable();

Animal
6 Nov 2009, 7:14 AM
I don't understand that stream.

Basically its simple. The second combo has a Store. But its empty.

It gets loaded from the "select" event of the first one.

It should be that simple.

alien3d
6 Nov 2009, 7:47 AM
1.If i define empty store .Problem occour when user press the second combobox first.Then choose the first combobox.


this.store.getCount is not a function

2.To counter this problem i have added dummy data


department_loc_store = new Ext.data.SimpleStore({
reader:department_loc_reader,
store :['','']
});

3.When user choose the first combobox,it will json data from the server.But when user click the second combobox.It will load dummy data and not append it.
4.The last choice is to disable the second combobox and enable it when combobox first select event fire.

Animal
6 Nov 2009, 10:35 AM
Create the store empty and use it.