Tuesday, October 27, 2015

Read SubGrid Records and Cell Values Using Javascript in MSCRM

Code Snippet:

Read SubGrid Records:

function ReadSelectedSubGridRecords() {
        if (document.getElementById("SubGridName")) {
        var grid = document.getElementById("SubGridName").control;
        for (var row = 0; row < grid.get_selectedRecords().length; row++)
            alert(grid.get_selectedRecords()[row].Name);
    }
}

Read SubGrid cell value:

function GetSubGridCellValues() {
    if (document.getElementById("SubGridName")) {
        var grid = document.getElementById("SubGridName").control;
        var ids = gridControl.get_allRecordIds();
        for (i = 0; i < ids.length; i++) {
            alert(gridControl.getCellValue('fullname', ids[i]));
        }
    }
    else {
        setTimeout("GetSubGridCellValues();", 2500);
    }
}

No comments:

Post a Comment