Attach Logic to Sub-Grid after being Loaded in CRM 2013

I did not find a script online for CRM 2013 that could help. So here it goes:

 

function subGridOnload()
{
var grid = $(‘#gridname’);  //Replace Grid name here
if (grid == null)
{
// delay one second and try again.
setTimeout(subGridOnload, 1000);
return;
}
 
if(grid[0] == undefined)
{
  // delay one second and try again.
setTimeout(subGridOnload, 1000);
return;
}
 
  if(grid[0].control == undefined)
{
  // delay one second and try again.
setTimeout(subGridOnload, 1000);
return;
}
 
  if(grid[0].control == null)
{
  // delay one second and try again.
setTimeout(subGridOnload, 1000);
return;
}
 
if (grid[0].control.get_totalRecordCount() == -1)
{
   // delay one second and try again.
setTimeout(subGridOnload, 1000);
return;
}

//Logic goes here

}

Note: This is unsupported and might break in future!

Hope it helps!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s