PDA

View Full Version : How to update the Combobox content when modifying a grid value



chamlie
4 Feb 2008, 5:28 PM
Hi All,
I want to edit a field value in a grid and the changed grid value will load the datastore from the server side.
However, I have faced a problem that when I using Ext.getCmp to get the element out,
it is undefined.
PHP Code:
colModel = new Ext.grid.ColumnModel([ //instantiate ColumnModel

{
align: 'left',
dataIndex: 'BlockID',
id : 'BlockID',
header:'Block ID',

sortable: true,
width: 20 ,
editor: new Ext.form.TextField({
allowBlank: false,
listeners:{change:function(){
var parent=Ext.getCmp('combobox-productid');
//I cannot get the 'combobox-productid' compoment

var store =new Ext.data.Store({
baseParams:{ BlockID: this.value,
task: 'getProductList'
},
proxy:new Ext.data.HttpProxy({
url: 'getresult.php',
method:'POST'
}),
reader:new Ext.data.JsonReader({
id:'ProductID',
fields:['ProductID']
}),
remote:true
});
parent.store=store;
parent.displayField='ProductID';
parent.valueField ='ProductID';
}},
triggerAction:'all',
typeAhead :true,
anchor:'100%'


}) //close editor



},{
align: 'right',
dataIndex: 'ProductID',
header: "Product ID",
width: 20,
id:'combobox-productid',
defaults:{xtype:'combo'},
.....

})//,



I think it may due to the Ext.getCmp('combobox-productid') inside a textfield which cannot get the 'combobox-productid', but How can I solve it?

Thank you

Condor
4 Feb 2008, 11:32 PM
The id is the id of the column, not of the editor.

ps.
1. I would attach an event to the update event of the store and not to the editor.
2. You shouldn't recreate the store every time; just reload the store with different parameters.

chamlie
10 Feb 2008, 5:06 PM
Thx you Condor

I have followed your guideline and pass the request to the event to handle.

However, I don't know how to put the retrieved store from to event back to the data store in the column. What can I do?

http://extjs.com/forum/showthread.php?t=25761