You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: powerapps-docs/developer/model-driven-apps/clientapi/reference/events/grid-onrecordselect.md
+45-2Lines changed: 45 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -3,20 +3,63 @@ title: "Grid OnRecordSelect event (Client API reference) in model-driven apps| M
3
3
description: Includes description and supported parameters for the grid OnRecordSelect event.
4
4
author: jasongre
5
5
ms.author: jasongre
6
-
ms.date: 03/12/2022
6
+
ms.date: 06/29/2023
7
7
ms.reviewer: jdaly
8
8
ms.topic: reference
9
9
applies_to: "Dynamics 365 (online)"
10
10
search.audienceType:
11
11
- developer
12
12
contributors:
13
13
- JimDaly
14
+
- ericregnier
14
15
---
15
16
# Grid OnRecordSelect event (Client API reference)
16
17
17
-
The `OnRecordSelect` event occurs when a single row (record) is selected in the editable grid. This event won't occur if a user selects different cells in the same row, or selects multiple rows.
18
+
The `OnRecordSelect` event occurs when a single row (record) is selected in an editable grid. This event doesn't occur if a user selects different cells in the same row, or selects multiple rows.
18
19
20
+
## Example: Override the default open behavior in model-driven grids
19
21
22
+
When you want to customize the way that a table record opens from the [Power Apps grid control](../../../../../maker/model-driven-apps/the-power-apps-grid-control.md), you can control how this opens with a JavaScript function associated with the grid `OnRecordSelect` event.
23
+
24
+
The following example ensures that the record opens using the form specified by the `pageInput``formId` value using the [Xrm.Navigation.navigateTo](../Xrm-Navigation/navigateTo.md) method. In this example, the form and grid must belong to the same entity.
25
+
26
+
### Step 1: Create a web resource
27
+
28
+
Create, save, and publish a JavaScript (JS) web resource that contains the following code:
More information: [Create or edit model-driven app web resources](../../../../../maker/model-driven-apps/create-edit-web-resources.md)
46
+
47
+
### Step 2: Enable Power Apps Grid Control
48
+
49
+
Follow these steps to enable the **Power Apps grid control** as the main grid (table view) or within a model-driven form subgrid:
50
+
51
+
-[Use as main grid](../../../../../maker/model-driven-apps/the-power-apps-grid-control.md#add-the-power-apps-grid-control-to-views-for-an-entity)
52
+
-[Use as subgrid](../../../../../maker/model-driven-apps/the-power-apps-grid-control.md#add-the-power-apps-grid-control-to-a-subgrid)
53
+
54
+
### Step 3: Register the custom behavior on OnRecordSelect Event
55
+
56
+
When you enable the **Power Apps grid control**, an **Events** tab appears. Select the **Events** tab:
57
+
58
+
1. Under the **Form Libraries** section, add the Form Library from the web resource created.
59
+
1. Under the **Event Handlers** section, select the event **OnRecordSelect** and select **Add** and a popup appears.
60
+
1. In the popup, select the form library just added and the function name `Example.OnSelect`. This is the name of the JavaScript function created in the web resource. Make sure to check the option **Pass execution context as first parameter**.
61
+
62
+
More information: [Power Apps grid control](../../../../../maker/model-driven-apps/the-power-apps-grid-control.md)
0 commit comments