For me, one of the most promising features in UR 0.1 was the Enhanced Subgrid Capabilities. After reading the SDK articles and playing with it, my excitement somewhat subsided, yet I believe it is a step in right direction and hope for additional key features in future versions.
According to the SDK (v7.1.0) the Enhanced Subgrid Capabilities are available only for Microsoft Dynamics CRM Online with RU 0.1 applied. It is unclear if and when these features will be available for on-premise deployments.
Before describing the full half of the glass, here is what I am missing:
- All Grid types support, not just Subgrid: I would like to have a similar API for any type of grid control, such as associated view grid and entity level grid
- Grid Row selection event: An event raised when a grid row is selected would improve code elegancy and performance as it will prevent the need for some ugly ass polling code to determine if and which row was selected
- Access Grid row data: a supported method to access all row data, not just entity name, record id and primary attribute. This will prevent a server query to retrieve data which has already been sent to the client side
- Set Custom View: allowing developers to set the Grid view dynamically with a function similar to addCustomView (which exists for Lookup controls) will prevent usage of the common unsupported method used to achieve this required capability
What features did we get? following is a brief description of the objects, events and methods of this new API along with my notes:
- GridControl object
- onLoad event – according to the SDK, this event fires whenever the subgrid is refreshed. Actually, this event is not raised when the containing form is loaded or when the grid’s view is manually/programmatically changed, which in my opinion counts as a refresh.
This event also fires when adding grid records, deleting grid records, on programmatic grid refresh and column sorting event.
When deleting a grid record, the event fires twice – before and after the delete dialog. - addOnLoad – adds an event handler to the subgrid onLoad event
- removeOnLoad – removes an event handler from the subgrid onLoad event
- getGrid – get reference to the Grid object via the GridControl object
- getViewSelector – get reference to the ViewSelector object via the GridControl object
- getEntityName – get the logical name of the entity which data is displayed in the grid
- onLoad event – according to the SDK, this event fires whenever the subgrid is refreshed. Actually, this event is not raised when the containing form is loaded or when the grid’s view is manually/programmatically changed, which in my opinion counts as a refresh.
- Grid object
- getRows – returns a collection of GridRow objects, limited to the Grid rows in the currently displayed page
- getSelectedRows – returns a collection of selected GridRow objects for every selected Grid row in the currently displayed page.
Since form subgrid does not allow multiple record selection, this function always returns one GridRow object - getTotalRecordsCount – returns the total number of records that match the filter criteria of the applied view
- GridRow object
- getData – returns a GridRowData object for the selected GridRow
- GridRowData object
- getEntity – returns a GridEntity for the GridRowData object
- GridEntity object
- getEntityName – returns the logical name for the record in the specified row.
This can be useful for mixed entity grids such as Activities grid - getEntityReference – returns a Lookup object representing the record in the specified row
- getId – returns the GUID for the record in the specified row
- getPrimaryAttributeValue – returns the primary attribute value for the record in the specified row
- getEntityName – returns the logical name for the record in the specified row.
- ViewSelector object
- getCurrentView – get a reference to the current applied view
- isVisible – determine whether the view selector control is visible
- setCurrentView – set the current view.
This function has no effect if the View Selector object is invisible
This unmanaged solution contains code sample demonstrating the various objects, events and method usage via the Account form. As mentioned, this code will work only in Microsoft Dynamics CRM Online with RU 0.1 applied.
This solution adds a ‘DEMO SUBGRID’ button to the Account form, do not install this solution on your production environment.