web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

coloring text in cell of subgrid

(0) ShareShare
ReportReport
Posted on by 76

Hello. How can I change the color of value(text) in column for each row in subgrid(CurrentView) by script ?

Thank you.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    Hi,

    You have add a web resource in a view. See below image

    5344.Capture.PNG

    function OfferStatus(rowData, userLCID) {
    debugger;

    if (rowData == null || rowData == 'undefined') return;

    // read rowdata
    var str = JSON.parse(rowData);

    var coldata = str.fieldschemaname(f1);

    // F2 field is two options having yes and no values based on that we have to change the color of the grid row
    var submitted=str.fieldschemaname(f2);
    //get row/record guid
    var rowId = str.RowId;

    if (coldata == null || coldata == 'undefined' || coldata.length < 1)

    return;

    if(submitted=="Yes")
    {
    $('span:contains("Yes")').closest('tr').css('background-color', 'Coral')

    }

    else if (submitted=="" ||submitted=="No" )
    {
    $('span:contains("No")').closest('tr').css('background-color', 'White')
    $('span:contains("")').closest('tr').css('background-color', 'White')

    }
    }

    Thanks Ridhima

  • Verified answer
    Shaminderpal Singh Profile Picture
    1,565 on at

    @Ridhima- Modifying the dom isn't supported and should be avoided.

    @Marina-

    The better way would be to add different color icons in front of your cell.

    Please refer -https://docs.microsoft.com/en-us/dynamics365/customer-engagement/customize/display-custom-icons-instead

    -Shaminder

  • Marina Karapetyan Profile Picture
    76 on at

    Hello Ridhima. Thank you for answer.

    When this function works ? Where you write the call of OfferStatus() function ?

    I need it works every time when open this subgrid.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Marina ,

    There is no supported way to change the text color , only you can add icon to above Shaminder suggested URL .

    You can also see below post ,unsupported way change row color -

    passion4dynamics.com/.../color-subgrid-in-microsoft-dynamics-crm-365

  • Marina Karapetyan Profile Picture
    76 on at

    Hello Shaminder.

    Thank you for answer.

  • Marina Karapetyan Profile Picture
    76 on at

    Hi Goutam, thank you for answer.

    As you clearly understand me, i don't need any icon, I need colored exactly the text in cell, not background, but text, because it is url, but shows in black color.

    However, if there is no way, but you have such task, how you resolve it ?

  • Suggested answer
    Community Member Profile Picture
    on at

    I know this is not the supported way but one time client needed to change the row color according to other field value in subgrid

    We have used this code and I have added image. you have to call this function where you have edit view column in views. View that used in subgrid. There can you give funtion name

    Thanks

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Marina ,

    I understand your requirement but seems this is by design and there is no way to change  the text color .You should not do the changes with unsupported way . I believe you know the meaning of unsupported , the customization you did , may not work when you upgrade to upper version. For this requirement I would suggest to convince your customer accordingly.

    There is another option by retrieving the subgrid data and bind the data in a custom HTML webresource using third party grid (JQuery ,easyUI etc ). Apply your color in the custom grid.

  • awalters Profile Picture
    3,079 on at

    We looked at doing some of this type of modification, but actually ended purchasing a third party add-on called CRM Grid Plus.  Allows it to be modified easily in a GUI, no code, and has lots of options around indenting, colouration, column size and label modification, etc...  And quite affordable, at least for our size of org.

    No affiliation with the company - just think it's a solid option.  :-)

  • Marina Karapetyan Profile Picture
    76 on at

    Hi Allison, thank you for your answer.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans