I created 2 grid in for loop context and the onRowSelect event was attached, however,when cell was selected in the first grid, the grid couldn’t find the correct row of the first grid with the rowid param, here is the code:
[code]
for(var j=0;j<cIds.length;j++){
var cellId = cIds[j];
var cellName = tree.getItemText(cellId);
var gridId = “bizDatoGrid”+j;
var bizXml;
bizXml = “some.xml”;//xml data from server side
var docXml = toXML(bizXml);//convert xmlString to xml document
var node = docXml.getElementsByTagName(“rows”)[0];;
var maxCellCnt = node.getElementsByTagName(“userdata”)[0].firstChild.nodeValue;//colume count
var bizDatoGrid = new dhtmlXGridObject(gridId);
var headerHtml = "<div style=\"width:100%;text-align:center;\"> <img src=\"../../htc/Tabstrip/images/eoms/treeicon_danyuan.gif\" align=\"absmiddle\"> <span><b>Cell 1</b></span></div>";
var headerText = "Layer";
var colIds = "layer";
var colAligns="left";
var colWidths = "100";
for(var i=1;i<=maxCellCnt;i++){
headerHtml+=",#cspan,#cspan,#cspan";
headerText+=",Cell,frameid,framecolor";
colIds +=",frame"+i+",frame"+i+"_id,frame"+i+"_color";
colWidths+=",70,0,0";
colAligns+=",center,center,center";
}
bizDatoGrid.setHeader(headerHtml);
bizDatoGrid.attachHeader(headerText);
bizDatoGrid.setColumnIds(colIds);
bizDatoGrid.setInitWidths(colWidths);
bizDatoGrid.setColAlign(colAligns);
bizDatoGrid.setEditable(false);
bizDatoGrid.enableAutoWidth(true);
bizDatoGrid.enableAutoHeight(true);
bizDatoGrid.enableContextMenu(menu);//menu declared as global variable
bizDatoGrid.attachEvent("onRowSelect", function(id,ind){
bizDatoGrid.clearSelection();
if(ind>0){
var roomid = bizDatoGrid.cellById(id, ind).getValue();//here was the problem when i debug the code, the cellById function can't work when i selected a cell of the first grid, but it worked well when i selected a cell of the second grid.
if(dhxWins.window("w1"))dhxWins.window("w1").close();
var w1 = dhxWins.createWindow("w1", 0, 0, 320, 400);
w1.setText(roomid);
w1.clearIcon();
w1.denyResize();
w1.button("park").hide();
w1.button("minmax1").hide();
w1.button("minmax2").hide();
w1.attachHTMLString("<div></div>");
w1.centerOnScreen();
}
});
bizDatoGrid.init();
bizDatoGrid.setSkin("dhx_building");
bizDatoGrid.parse(docXml,"xmlA");
}[/code]
is it a bug of the dhtmxgrid component? please help me out, thanks in advance!