Color Subgrid in Microsoft Dynamics CRM 365

No comments

Microsoft dynamics CRM is definitely turning colorful and interesting(has been always to me but in terms of look and feel). Recently subgrid’s in CRM have taken a full swing be in terms of editing them or looking colorful.

I tried something with my dynamics crm 365 trial and this is how it looks :

color

 

Now if i talk about above picture – it is actually a combination of Out of the box feature and UNSUPPORTED feature.

  1. The header of the subgrid can be configured to use any color by clicking on subgrid properties from form editor like below:color2.PNGto make the most of out of this color option you need to know the exact hexa/html code of the color, i used this website to get the code : http://htmlcolorcodes.com/
    colo3
  2. For the second feature i have actually used unsupported javascript below :function subGridOnload()
    {
    var grid = $(‘#contactcasessgrid’); //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

    $(‘#contactcasessgrid td’).filter(function() {
    return $(this).text() == ‘Resolved’;
    }).closest(‘tr’).css(‘background-color’, ‘Green’);
    $(‘#contactcasessgrid td’).filter(function() {
    return $(this).text() == ‘Active’;
    }).closest(‘tr’).css(‘background-color’, ‘Red’);

    }

    As seen in the above code , i am assigning Gerrn color to Resolved cases and Red color to Active cases on the subgrid.
    you can read any value in the subgrid and apply any color to it.

    hope this helps.
    cheers!

 

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.