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
415
Row selector missing when row selected using JavaScript
posted

I have the following code to select a row using BLOCKED SCRIPT

function DataGrid_SetSelectedRow(gridName, row, setActive, clearSelection) {
    var grid = DataGrid_GetGrid(gridName);
    if (!grid) { ErrorHandler_Error('DataGrid_SetSelectedRow''Unable to find grid.'); return; };
 
    var behaviours = grid.get_behaviors();
    if (!behaviours) { ErrorHandler_Error('DataGrid_SetSelectedRow''Unable to find grid behaviours.'); return; };
 
    var selection = behaviours.get_selection();
    if (!selection) { ErrorHandler_Error('DataGrid_SetSelectedRow''Unable to find grid selection behaviour.'); return; };
    if (clearSelection == undefined) clearSelection = false;
    if (clearSelection == true)
        selection.get_selectedRows().clear();
 
    if (row == undefined || row == nullreturn;
    selection.get_selectedRows().add(row);
 
    var activation = behaviours.get_activation();
    if (!activation) { ErrorHandler_Error('DataGrid_SetSelectedRow''Unable to find grid selection behaviour.'); return; };
 
    if (setActive == undefined) setActive = true;
    if (setActive == true)
        activation.set_activeGroupedRow(row, true)
}

The row is selected as expected but the row selector and row number is missing 
until I actually click the row. The row selector is just a white square. I whought
I thought I might need to make the row active so I tried that too but still cant 
get it working.
Parents
No Data
Reply
  • 19693
    Verified Answer
    posted

    Hello Rich,

    You are correct you are missing the active row and you can make it active by setting the active cell:

            var grid = $find('WebDataGrid1');

            var row = grid.get_rows().get_row(2);

            grid.get_behaviors().get_selection().get_selectedRows().add(row);

            grid.get_behaviors().get_activation().set_activeCell(row.get_cell(0));

     

    activeGroupedRow is used when Grouping ( of WebHierarchicalDataGrid ) is enabled

    Let me know if you need further assistance regarding this.

Children
No Data