PDA

View Full Version : How to display key in combobox



sachin sachdeva
10 Mar 2011, 12:29 AM
Hello ,i am using editable grid and inside that grid i am using combo box..Now my requirement is after rendering i am able to render the value of combo box but some how i need to render the selected value that the key of combo box my code is as given below


var cm = new Ext.grid.ColumnModel({
// specify any defaults for each column
defaults : {
// autoWidth : true,
sortable : true, // columns are not sortable by default
autoScroll : true
},
columns : [
{
header : "Content Category",
dataIndex : 'category',
width : 80,
menuDisabled : true,
hidden : false,
editor : categories, //-----categoreis--//defined below
renderer : function(val, metaData) {
metaData.css = 'x-grid3-col x-grid3-cell';
return val;//-----here i want to return key---//
}




var categories = new Ext.form.ComboBox({
editable : false,
typeAhead : true,
triggerAction : 'all',
lazyRender : true,
mode : 'local',
selectOnFocus : true,
emptyText : 'Select the Content Category...',
store : firstLevelCategories,
valueField : 'Id',
displayField : 'displayText',
fieldLabel : 'Content Category',
allowBlank : true,
listeners : {
select : {
fn : function(combo, value) {
var modelDest = Ext.getCmp('subCat');
modelDest.setValue('');
modelDest.store.removeAll();
var selectedValue = value.data.field1;
Ext.Ajax.request({
url : 'filter.jsp',
method : "POST",
params : {
firstLevelCategory : selectedValue
},
success : function(result) {
var responseJSON = Ext
.decode(result.responseText);
modelDest.store.loadData(responseJSON);
}
});
var index = Egrid.getSelectionModel().getSelectedCell();
var rec = store.getAt(index[0]);
rec.set('contentCategory', '');
}
}
}
});

rivarecords
10 Mar 2011, 5:49 AM
Try this for your renderer:




renderer: function(value){
var displayValue="",
var c_index =-1;
c_index=yourstore.find("value",value);
if(c_index>=0){
displayValue=yourstore.getAt(c_index).get("text")
}
return displayValue;
}

sachin sachdeva
14 Mar 2011, 2:56 AM
thanx ravi it is working fine now