Write scripts for subgrids

Applies To: CRM Online

With Kemas Kini 1 Microsoft Dynamics CRM Online 2015 you can do more with subgrid controls in forms by using new events and objects.

Untuk organisasi Microsoft Dynamics CRM Online, ciri ini hanya tersedia jika organisasi anda telah dikemas kini kepada Dynamics CRM Online 2015 Update 1. Ciri ini tidak disediakan bagi Dynamics CRM (di premis).

Subgrid OnLoad event

Subgrids load asynchronously from the form so you can’t reliably get access to the data in the subgrid in the form OnLoad event. But you can set an event handler for the OnLoad event of the subgrid. This event will occur each time the data in the grid is refreshed, this includes when users sort the columns of the grid.

There is no user interface to add new event handlers for this event, so if you want to do so, you must use code in another event, typically the form OnLoad event to use the GridControl.addOnLoad method. To remove event handlers for this event, use the GridControl.removeOnLoad method.

Subgrid object model

The diagram below shows the objects you can access from a subgrid in a form.

Grid control objects

The subgrid control is referred to as a GridControl in this context. As an Xrm.Page.ui control, the subgrid has all the methods available to all controls in addition to the refresh method.

The GridControl is the same object passed to a command bar or ribbon actions or rules using the <CrmParameter> (RibbonDiffXml) when available when the SelectedControl parameter is selected.

Change views with the ViewSelector

When a subgrid is configured to display a view selector you can get or set the current view. Use the GridControl.getViewSelector method to access the view selector and then the ViewSelector.getCurrentViewgetCurrentView and ViewSelector.setCurrentView methods to get or set the current view with a lookup object.

Get data from the grid

Use the GridControl.getGrid method to access the grid. Use the Grid.getRows method or Grid.getSelectedRows method to get a collection of GridRow objects. You can then access a reference to each record in the row by chaining together the GridRow.getData, GridRowData.getEntity, and GridEntity.getEntityReference methods.

Lihat Juga

Microsoft Dynamics CRM 2015 and Microsoft Dynamics CRM Online
Send comments about this topic to Microsoft.
© 2015 Microsoft. All rights reserved.