PDA

View Full Version : Combo Box in grid column does not displays display name after adding new row



mandardadpe
18 Nov 2013, 2:25 AM
Hi,

I have added combo box in grid column :
[CODE]

{
text : 'Account Name',
flex : 1,
align:'left',
sortable : false,
dataIndex : 'HotelAccounts',
editor: {
xtype:'combo',
autoSelect:true,
allowBlank: false,
id: 'hotelAccDayCombo',
emptyText:'Choose Account',
valueField:'id',
displayField: 'text',
//triggerAction: 'all',
forceSelection: true,
//editable:false,
queryMode: 'local',
typeAhead: true,
store:accountComboStore
},renderer: comboBoxRenderer(Ext.getCmp('hotelAccDayCombo'))

It works very fine, when I edit existing record, but in case of adding new record I can not see display name in column. Following is my renderer code:

var comboBoxRenderer = function(combo) {
return function(value) {
// alert(value);
var idx = Ext.getCmp('hotelAccDayCombo').getStore().find(Ext.getCmp('hotelAccDayCombo').valueField, value);
var rec = Ext.getCmp('hotelAccDayCombo').getStore().getAt(idx);
return (rec === undefined ? '' : rec.get(Ext.getCmp('hotelAccDayCombo').displayField) );


};
}

"idx" returns as " -1" so record displays as undefined.
Also,this is not constant, so is it Ext JS Bug? Some thing is going wrong with "store.find();" method.

scottmartin
18 Nov 2013, 8:40 AM
"idx" returns as " -1" so record displays as undefined.

When you create a new record, you should have a valid ID (eg: autoInc) returned from the server?

mandardadpe
18 Nov 2013, 9:27 PM
When you create a new record, you should have a valid ID (eg: autoInc) returned from the server?

When I add new record , I have records in drop down as I am sending ajax on add button. But it seems renderer function is not returning output. It is not issue of auto inc id , sometimes find() method doesnot return output though it has value field.