RE: How to get selected rows of grid and subgrid in a editable grid list view?
In the form editor, add a new button to the form.
Set the Display Rule for the button to "Custom JavaScript."
In the Custom JavaScript area, enter the following code:
csharpCopy codefunction showHideButton() {
var gridControl = Xrm.Page.getControl("subgrid_name");
var selectedRows = gridControl.getGrid().getSelectedRows();
if (selectedRows.getLength() > 0) {
Xrm.Page.ui.controls.get("button_name").setVisible(true);
} else {
Xrm.Page.ui.controls.get("button_name").setVisible(false);
}
}
Replace "subgrid_name" with the name of your subgrid and "button_name" with the name of your button.
Save and publish the changes to the form.
Open the record form and select one or more rows in the subgrid.
The button should appear or disappear based on the number of selected rows.
Note that this code assumes that the subgrid is on the same form as the button. If the subgrid is on a different form, you may need to modify the code to reference the correct form and control names.