Quantcast
Channel: Microsoft Dynamics 365 Community
Viewing all articles
Browse latest Browse all 64797

CRM 2015 Online - Accessing Subgrid data using Javascript

$
0
0

In CRM 2015 online, the grid control has new methods and events to assist the developer to get additional data about the grid like Ids or an array of selected records. In this blog post, I’ll show you two applications you might need to apply during your development.

When a subgrid control is added to the form the following functions can be consumed:

  • GridControl: use this if you want to hookup new event handlers
  • GridRowData: use this to access the values of each columns/attribute
  • GridEntity: use this to get the name of the entity and the Id of the selected record
  • ViewSelector: get or set the view selector

Imagine you have an Account form with a sub-grid of Addresses. You want to be able to select an address from the sub-grid and have it copy the data into the address fields on the Account. The grid control gives you the ability to do this.

I have added a subgrid to the Account form and added the composite field of Address1. In the Command bar, I added a custom button and called it Copy Address. This button has custom logic that accesses the grid control, gets the selected row and copies each attribute to the Address1: Name and Address1: Composite field. The grid control is aware of the added columns to the view and not the entire fields of the entity.

image

Select one of the Address records and click Copy Address in the Command Bar.

image

As you can see, Address1_composite field has all values from the first selected record.

The Command Bar button executes the logic to access the grid control as follows:

clip_image002

The first three lines in the function are responsible for accessing the control and getting the selected rows. In real applications you would need to check for nulls before using references.

For more information about the grid control, check the MSDN documentation.


Viewing all articles
Browse latest Browse all 64797

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>