Use JavaScript to check the “Select” box in List/Library Control

Use Case:

a) User selects a row in the List Control
b) Buttons appear in the Control’s toolbar
c) User clicks a button, and JS code update(s) fields in the selected row
d) Then the fd.control(“ControlName”).refresh is executed so the user can see the update(s)

After the refresh, the row that was selected by the user is unselected.

What we want to happen:

After the refresh, we want the row that was selected prior to the refresh to be programmatically selected again so the user can click another button and continue working on the row.

Here is the code sample for a button that updated the selected row:

const high = {
    icon: 'ChevronUpEnd6', 
    class: 'btn-light', 
    text: 'High',
    visible: true,
    location: 1,
    click: function() {
        sp.web.lists.getByTitle("Requirement").items
        .getById(selectedItemID)
        .update({Priority: "High"});
        fd.control('ListRequirement').refresh();
       // INSERT CODE HERE TO RE-SELECT THE ROW
    }
};

In this code, the getById method uses the Item's internal SharePoint Id, but that is not the Row Id of the row in the Control.

Hello @vhancock,

You can test this code to re-select rows:

//get selected rows
var selected = fd.control('Control1').widget.select()

//select rows
fd.control('Control1').widget.select(selected)

//clear selection
fd.control('Control1').widget.clearSelection()

Please find more information in kendo.ui.Grid documentation.