PDA

View Full Version : combobox json and sending a parameter



kinchyle
15 Nov 2009, 8:02 PM
I'm having a hard time with the combobox. I've read from the learning center, tried going throught he api docs and code. Been searching for 2 days in the forums...

I've made it past having the combobox expand on click like html
I've made it past using an id and text value using a renderer

Now I'm stuck on sending a parameter via the jsonstore. Every which way I send it , it just shows the text. I tried doing a function but it sent the function code.

I'm having a problem in the code where it says // !!!!! HAVING THE PROBLEM HERE



// create reusable renderer for ComboBox
Ext.util.Format.passComboRenderer = function(combo,p,record){
return function(value,p,record){
var comboRecord = combo.findRecord(combo.valueField, value);
return comboRecord ? comboRecord.get(combo.displayField) : record.data[this.dataIndex];//combo.valueNotFoundText;
}
}

// Combo var
var passCombo = new Ext.form.ComboBox({
valueField: 'id',
displayField: 'text',
store: new Ext.data.JsonStore({
method: 'PUT',
url: '/sent_to_me.cgi',
baseParams:{
// !!!!!!!!! HAVING THE PROBLEM HERE
extra_p: 'need_to_send_a_dataIndex_from_another_column' //I've tried things like record.data.other_index and this.other_index even doing a function but it sends the function text
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
},
root: 'results_list',
nocache: false,
loadMask: false,
fields: ['id', 'text']
}),
mode: 'remote',
triggerAction: 'all',
selectOnFocus:true,
forceSelection:true,
editable: false,
typeAhead: false,
lazyRender: true,
lazyInit: false,
listeners: {
focus: function(obj) {
obj.expand();//.defer();
}
}
});

// COLUMN CODE

header: 'Pass Me',
dataIndex: 'pass_index',
id: 'pass_name',
editor: passCombo
renderer: Ext.util.Format.passComboRenderer(passCombo)

kinchyle
17 Nov 2009, 8:11 PM
I think I figured it out using a listener with a beforeload.