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
4110
UltraWebGrid iteration in javascript
posted

Please help. I am iterating my UltraWebGrid in the BeforeRowTemplateOpenHandler to determine if the row I am on has the value "Other" in the text of the 3rd cell. If it has Other in it, I want to display DivB of my RowEditTemplate, otherwise I want to display DivA. I am doing something wrong, because it always displays DivB, no mater what row I select. Can anyone tell me what I need to do to fix this, because I'm not seeing it.

function igMyGrid_BeforeRowTemplateOpenHandler(gridName, rowId, templateId) {
    var grid = igtbl_getGridById(gridName);
    var len = grid.Rows.length;
    for (var x = 0; x < len; x++) {
        var name = grid.Rows.getRow(x).getCell(3).getValue();
        if (name.substring(0,5)=="Other" || name.substring(0,5)=="other") {
           igtbl_getElementById(templateId).children["divControls_A"].style.setAttribute('display', 'none');
            igtbl_getElementById(templateId).children["divControls_B"].style.setAttribute('display', '');
        }
        else {
            igtbl_getElementById(templateId).children["divControls_A"].style.setAttribute('display', '');
            igtbl_getElementById(templateId).children["divControls_B"].style.setAttribute('display', 'none');
        }
     
    }
 

}

Parents
No Data
Reply
  • 13438
    Verified Answer
    posted

    Hello Daryl,

     

    Please let me check if I understand your goals correctly. You want to open the Template with condition regarding the currently selected row. If so you don’t need to cycle through all rows. If you cycle the result will be always the result of the last row of the grid. Here you have only to get the current selected (active) row and to *.getCell(3) of this row and check its content.

Children