Sometimes we get requirement to show colour encoding on sub-grid in CRM 2013 forms. One of the
Queries I received was ways to achieve them. Here is a sample of what I tried on Case sub-grid on
Vanilla CRM Account form:
Here is the script:
I have got of lot of feedback to put more details of where to put scripts and stuff, so here it goes.
Sub-grid name can be found from FORM EDITOR. Refer screen below(Double click the sub-grid will give a property window):
Now the script, Add the below function to form onload
function subGridOnload()
{
var grid = $(‘#accountcasessgrid’); //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 Replace status names and colours as required
$(‘#accountcasessgrid td’).filter(function() {
return $(this).text() == ‘Resolved’;
}).closest(‘tr’).css(‘background-color’, ‘green’);
$(‘#accountcasessgrid td’).filter(function() {
return $(this).text() == ‘Active’;
}).closest(‘tr’).css(‘background-color’, ‘yellow’);
}
Hope it helps!
Ask your Query : Click here
Note: It is unsupported way and may break in future if Microsoft changes rendering of sub-grids in a future release.
Trying to Learn Dynamics CRM: Download!
Learn Dynamics CRM App on Google Play store