I have two grids on a page, the first grid is always visible and the second grid loads when a row is selected in the first grid.
mygrid = new dhtmlXGridObject(‘gridbox’);
mygrid.setImagePath("…/codebase/imgs/");
mygrid.preventIECaching(true);
mygrid.setOnRowSelectHandler(doOnRowSelected);
mygrid.init();
mygrid.loadXML("…/Get.aspx",function(){mygrid.setColumnHidden(0,true);});
myDataProcessor = new dataProcessor("…/Update.aspx");
myDataProcessor.setUpdateMode(“off”);
myDataProcessor.setTransactionMode(“GET”);
myDataProcessor.init(mygrid);
myDataProcessor.enableDebug(true);
grid = new dhtmlXGridObject(‘gridbox1’);
grid.setImagePath("…/codebase/imgs/");
grid.attachEvent(“onEditCell”,function(s,id,ind){
if (ind==13) return false;
return true;});
shiftgrid.preventIECaching(true);
function doOnRowSelected(id){
var z=myDataProcessor.obj.getUserData(id,"!nativeeditor_status");
if (z==“inserted” || z==“deleted” || z==“updated”)
{return false;}
else {
myDataProcessor.setUpdated(id,true);
myDataProcessor.sendData();
grid.init();
grid.loadXML("…/Get1.aspx");}}
DataProcessor1 = new dataProcessor("…/Update1.aspx");
DataProcessor1.setUpdateMode(“off”);
DataProcessor1.setTransactionMode(“GET”);
DataProcessor1.init(shiftgrid);
DataProcessor1.enableDebug(true);
my problem is that whenever i select a row for the first time in the 1st grid the second grid shows up with the corresponding data. But when i select the same row again the data is not showing up and an update operation is being triggered (i noticed this in my debug popup with the !nativeeditor_status=). why is this happening?
There are two reasons for your problem
a) The way how you load data in grid
grid.init();
grid.loadXML("…/Get1.aspx");
this command may just add data to the existing dataset instead of reloading, the correct way is
//grid.init() - moved to the initial grid initialization code
grid.clearAll(true);
grid.loadXML("…/Get1.aspx");
b) The onRowSelect occurs only when you select different row , if you select the same row , which already selected - event will not trigger. To force event in all cases just attach it in next way
mygrid.setOnRowSelectHandler(doOnRowSelected,true);