Categories | Question details Back To List | ||
Setting cellId attribute Hi, Can you help me setting the id attribute to the cells. I tried within the function onEditCell(stage, rowId, cellIndex, newValue, oldValue){ if (stage == 2) { var cell=grid.cells(rowId,cellIndex); cell.setAttribute("id",rowId + '-' + cellIndex); } } i also tried within the initilazation mygrid.enableCellIds(true); Can you help me... nothing seems to work? Im using the dhtmlxgrid.js (//v.2.0 build 81107). Updating this file to newer version (//v.2.1 build 90316) causes my grid not working properly. further info about my code: //INCLUDING FILES <link rel="STYLESHEET" type="text/css" href="/codebase/dhtmlxgrid.css"> <script src="/codebase/dhtmlxcommon.js"></script> <script src="/codebase/dhtmlxgrid.js"></script> <script src="/codebase/dhtmlxgridcell.js"></script> <script src="/codebase/ext/dhtmlxgrid_splt.js"></script> <script src="/codebase/dhtmlxtreegrid.js"></script> <script src="/codebase/ext/dhtmlxtreegrid_lines.js"></script> //INITIALIZING GRID function doInitDhtmlx(){ mygrid = new dhtmlXGridObject('gridbox'); mygrid.imgURL = "/codebase/imgs/"; mygrid.attachEvent("onEditCell", onEditCell); mygrid.setSkin("pronto"); mygrid.splitAt(1); mygrid.enableTreeGridLines(); mygrid.enableLightMouseNavigation(true); mygrid.setSerializationLevel(true, false, false, true, false, false); mygrid.enableCellIds(true); mygrid.loadXML("/modules/access/matrix/get_access_matrix_grid_xml.php"); mygrid.init(); } function doSubmit(){ var xmlStr = mygrid.serialize(); document.getElementById('DATA').value = xmlStr; document.forms['hidden'].submit(); } function onEditCell(stage, rowId, cellIndex, newValue, oldValue){ if (stage == 0) { if (cellIndex==0){ return false; } } if (stage == 2) { var cell=grid.cells(rowId,cellIndex); cell.setAttribute("id",rowId + '-' + cellIndex); var status = mygrid.getUserData(rowId, "status"); status |= 4; mygrid.setUserData(rowId, "status", status); return true; } return true; } Answer posted by dhxSupport on Jun 23, 2009 03:08 enableCellIds(true) method sets cell ids which could be used in the automation testing. In that case <td> html elements have attributes <td id="c_0_1"> getAttribute/setAttribute cell's methods set or get attributes which was attached to the cell in xml: <cell id="some" custom="customAttributeVale">Cell value</cell> In such case "id" and "custom" attributes doesn't render like "id" and "custom" attribute of the <td> html element. This attribute become cell object properties. To get id of the cell like id of the <td> html element you can do: var cellObject=grid.cells(rowId,cellIndex); var attr=cellObject.cell.id; Answer posted by FilipWinters on Jun 26, 2009 01:49 Thank you dhx, i managed to make it work! Regards, Filip |