PDA

View Full Version : EditorGrid: ComboBox remote store picks data of previous row



msuresh
18 Feb 2011, 6:59 AM
Hi,

I am a using combobox inside the editor grid panel. I am loading remote store for this combo.

Whenever I click combo cell on the FIRST ROW it fetches data by making remote call. When I click on the SECOND ROW, it shows the data of the FIRST ROW. It is not making a new call to load. I am creating new instance of store for each row, but still I don't understand why it is taking data from first row store.

I tried different things, but could not figure out the problem.

Stuck here badly, looking for some help.



this.colModel = new Ext.grid.ColumnModel({
columns : [eType, {
dataIndex : 'selectedLogType',
hidden : true
}, {
header : 'System',
dataIndex : 'hostName',
width : 175
}, {
header : 'ASUP',
width : 260,
editable : true,
dataIndex : 'asupRange',
renderer : function(v, meta, r, ridx, cidx, str) {
meta.attr = 'ext:qtip="' + eMessage + '"';
var returnStr = "Select Date";
var asupRange = r.json.asupRange;
if (Ext.isDefined(v)) {
returnStr = Ext.util.Format.date(v, 'D M d Y, H:i T')
} else {
for (var i = 0; i < asupRange.length; i++) {
if (asupRange[i].asupId == r.data.selectedAsup) {
me.selectedAsupIds.push(asupRange[i].asupId);
return asupRange[i].asupDate;
}
}
}
storecnt++;
return returnStr;
},
editor : new Ext.grid.GridEditor(new Ext.form.ComboBox({
store : new Ext.data.JsonStore({
url : 'http://localhost/logview/asuprange',
root:'asupRange',
method : 'GET',
fields : [{name: 'asupDate', mapping: 'asupDate', type: 'date', dateFormat: 'U'},
'asupId', 'asupTitle', 'hostName']
}),
tpl: '<tpl for="."><div class="search-item">' +
'<span>{asupDate:date("D M d Y, H:i T")}</span>' +
'{asupTitle}' +
'</div></tpl>',
displayField:'asupDate',
itemSelector: 'div.search-item',
editable: false,
listWidth:500,
mode: 'remote',
triggerAction: 'all',
selectOnFocus:true,
listeners : {
select : function(cmbo, record, index) {
var rowIndex = cmbo.rowIndex;
me.setSelectedLogType(record.json, rowIndex);
me.loadLogTypes();
}
}
}), {
listeners : {
beforestartedit : function(editor) {
var combo = editor.field, record = editor.record;
combo.id = "combo"+editor.row;
alert(editor.row)
combo.rowIndex = editor.row;
combo.store.baseParams = {
"sysId" : editor.record.json.sysId,
"sn" : editor.record.json.sn,
"refasup": me.store.reader.jsonData.refAsupDetails.asupId,
"proximateDate": me.store.reader.jsonData.refAsupDetails.asupDate
};
combo.store.on('load', function(store, records, options) {
var data = store.reader.jsonData
if (data.error == "true" && data.success == "false") {
if (Ext.isDefined(data.msg)) {
combo.emptyText = data.msg;
}
}
});
},
single:false,
scope:this
}
})
}]
});


Regards,
Suresh

carl23934
18 Feb 2011, 7:43 AM
The same editor is used for all rows. If you want to load new data, do you have to do it manually by hooking into the beforeedit event.

Condor
18 Feb 2011, 7:58 AM
Isn't this the same question as I answered a few minutes ago?

You'll have to clear the lastQuery to force the combobox to reload:

delete combo.lastQuery;

msuresh
18 Feb 2011, 9:01 AM
Thanks Condor. Yes, I had opened the previous post yesterday for autoloading stores dynamically, as I didn't get any correct answer I ignored the previous logic and tried in a slightly different way.

I really appreciate your patience. Thanks a lot for giving me the right ideas to proceed.