Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
130
UltraWebGrid row styles on mouse over with alternate style replacement
posted

 Hello,

I'm looking for the best way to apply a row style onmouseover and then replace the alternate row styles onmouseout. In an asp.net Gridview I was able to add onmouse attributes at databinding with the row colors set programatically but I don't seem to be able to do that with the webgrid.

I've got some javascript that extracts the row index from the ID but I wonder if there is a better way?

 Thanks in advance!

 

Current Javascript code:

 function UltraWebGridRow_Over(gridName, Id, objectType)
    {      
        try {
            var Row = igtbl_getRowById(Id);
            var RowIndex = Row.Id.replace(gridName + "_r_","");
            setRowColor(Row, "in", RowIndex);
        } catch (e) {
        }
    }
  
    function UltraWebGridRow_Out(gridName, Id, objectType)
    { 
        try {
            var Row = igtbl_getRowById(Id);
            var RowIndex = Row.Id.replace(gridName + "_r_",""); 
            setRowColor(Row, "out", RowIndex); 
        } catch (e) {
        }
    }
  
    function setRowColor(Row, Direction, RowIndex)
    {
       var sColor = "#ffffcc"
       if (Direction == "out") {
        if (RowIndex % 2 == 0) {
            sColor = "white";
        } else {
            sColor="#EFF3FB";
        }
       }
        var cells = Row.getCellElements();
        for (var i = 0; i < cells.length; i++)
        {
            cells[i].style.backgroundColor = sColor;     
        } 
    }