PDA

View Full Version : How to get Row Index inside combo select?



msuresh
8 Jan 2011, 6:54 AM
Hi,
I need to pass the row index to a function when user selects something from the combo list.
What are the ways we can use to get the row position. The record what we are getting on select is of not much use in my case because its a nested JSON. I hope there should be a easy way however I am unable to search it in forum or google.

Appreciate your help.



editor : new Ext.grid.GridEditor(new Ext.form.ComboBox(
{
store : new Ext.data.JsonStore({
fields : ['asupDate','asupId']
}),
mode : 'local',
valueField : 'asupId',
displayField : 'asupDate',
typeAhead : true,
triggerAction : 'all',
emptyText : 'Select Date',
listeners : {
select : function(cmbo, record, index) {
// Stuck here: I need to find out the row position here which needs to be passed
// to setSelectedLogType
console.log(me.store.indexOf(record));//Not working
me.setSelectedLogType(record.json);
me.loadLogTypes()
}
},
lazyRender : true,
{
listeners : {
beforestartedit : function(editor) {
var combo = editor.field, record = editor.record;
console.log(combo)
combo.store.loadData(record.get('asupRange'));
}
}
})
...
...


Thanks,
Suresh

Condor
8 Jan 2011, 7:11 AM
editor: new Ext.grid.GridEditor(new Ext.form.ComboBox({
store: new Ext.data.JsonStore({
fields: ['asupDate', 'asupId']
}),
mode: 'local',
valueField: 'asupId',
displayField: 'asupDate',
typeAhead: true,
triggerAction: 'all',
emptyText: 'Select Date',
listeners: {
select: function (cmbo, record, index) {
var rowIndex = cmbo.rowIndex;
me.setSelectedLogType(record.json);
me.loadLogTypes()
}
},
lazyRender: true
}), {
listeners: {
beforestartedit: function (editor) {
var combo = editor.field,
record = editor.record;
combo.store.loadData(record.get('asupRange'));
combo.rowIndex = editor.rowIndex;
}
}
})

msuresh
8 Jan 2011, 9:10 AM
Thanks Condor. rowIndex shows undefined and I checked cmbo object and could not find rowIndex there.

Condor
8 Jan 2011, 11:09 AM
ComboBox doesn't have a rowIndex property! I explicitly add it in the beforestartedit event handler (check code again).

msuresh
8 Jan 2011, 5:54 PM
Long hours of trying for a solution and curiosity of giving a try for the new solution failed my eyes to look into the scroll bars. Shame on me :(

A small change on the last line gave me the row number. May be because I am using ExtJS 3.3



combo.rowIndex = editor.rowIndex

//changed to

combo.rowIndex = editor.row

beingrika
21 Nov 2012, 2:23 AM
ComboBox doesn't have a rowIndex property! I explicitly add it in the beforestartedit event handler (check code again).


So why doesn't post the whole code?!?!