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

















//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;

}



enableCellIds(true) method sets cell ids which could be used in the automation testing. In that case

html elements have attributes
getAttribute/setAttribute cell’s methods set or get attributes which was attached to the cell in xml:
Cell value
In such case “id” and “custom” attributes doesn’t render like “id” and “custom” attribute of the html element. This attribute become cell object properties.
To get id of the cell like id of the html element you can do:
var cellObject=grid.cells(rowId,cellIndex);
var attr=cellObject.cell.id;


Thank you dhx,



i managed to make it work!



Regards,



Filip