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
+5-23Lines changed: 5 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -16,31 +16,12 @@ contributors:
16
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
18
19
-
## Override the default open behavior in model-driven grids
19
+
## Example: Override the default open behavior in model-driven grids
20
20
There might be situations where you don't want the table record to open (which is the default behavior), but want a custom action to be performed such as opening a URL using JavaScript functions. Here is an example to acheive this using the [Power Apps Grid Control](../../../../../maker/model-driven-apps/the-power-apps-grid-control) and the `OnRecordSelect` event.
21
21
22
22
### Step 1: Create a web resource
23
23
24
-
Create a web resource to change the default behavior. In the following example, if you want to open a URL instead of displaying the record, you create a JavaScript web resource to perform that action.
25
-
26
-
1. Sign in to [Power Apps](https://make.powerapps.com) and select **Solutions** from the left pane.
27
-
28
-
2. Select **New solution**, and then complete the required columns for the solution.
29
-
30
-
|Column|Description|
31
-
|-----------|-----------------|
32
-
|**Display Name**|The name shown in the list of solutions. You can change this later.|
33
-
|**Name**|The unique name of the solution. This is generated by using the value you enter in the **Display Name** column. You can edit this before you save the solution, but after you save the solution, you can't change it.|
34
-
|**Publisher**|You can select the default publisher or create a new publisher. We recommend that you create a publisher for your organization to use consistently across the environments where you'll use the solution.|
35
-
|**Version**|Enter a number for the version of your solution. This is only important if you export your solution. The version number will be included in the file name when you export the solution.|
36
-
37
-
3. Select **Save**.
38
-
39
-
4. Open the solution, and then select **New** > **Other** > **Web resource**.
40
-
41
-
5. Enter the name of the web resource, and select the **Type** as **JavaScript (JS)**.
42
-
43
-
6. Select **Text Editor**, copy the code shown below, paste it into the text editor. This example uses the **contact** table. Set the `entityName` to the table you want.
24
+
Create, save and publish a JavaScript (JS) web resource that contains the following code. This example uses **contact** table. Set the `entityName` you want to use.
44
25
45
26
```JavaScript
46
27
functionOnSelect(context) {
@@ -52,7 +33,8 @@ Create a web resource to change the default behavior. In the following example,
52
33
Xrm.Navigation.navigateTo(pageInput);
53
34
}
54
35
```
55
-
7. Save and publish the web resource.
36
+
37
+
More information: [Create or edit model-driven app web resources ](../../../../../maker/model-driven-apps/create-edit-web-resources.md)
56
38
57
39
### Step 2: Enable Power Apps Grid Control
58
40
Follow these steps to enable the **Power Apps Grid Control** as the main grid (table view) or within a model-driven form subgrid.
@@ -64,7 +46,7 @@ Follow these steps to enable the **Power Apps Grid Control** as the main grid (t
64
46
When enabling the **Power Apps Grid Control**, an **Events** tab appears. Select the **Events** tab:
65
47
1. Under the **Form Libraries** section, add the Form Libary from the web resource just created.
66
48
2. Under the **Event Handlers** section, select the event **OnRecordSelect** and click Add, a popup will appear.
67
-
3. In the popup, select the form library just added and the Function name **OnSelect**. This is the name of the JavaScript function created in the web resource, and check the option **Pass execution context as first parameter**.
49
+
3. In the popup, select the form library just added and the Function name **OnSelect**. This is the name of the JavaScript function created in the web resource, and make sure to check the option **Pass execution context as first parameter**.
68
50
69
51
70
52
For more infomation, see [Power Apps Grid Control](../../../../../maker/model-driven-apps/the-power-apps-grid-control)
0 commit comments