serving the solutions day and night


Saturday, May 17, 2014

MS Dynamics CRM - Change Grid view background color

My client wants to change the grid view color based on the contact entity address type value is "Ship To". So i added a button in the contact entity "<ribbondiffxml>", but i didn't make it display, you can see there is no command in the "<displayrules>". I added new <customrule> to call the javascript("dns_contact") function ("BackGroundColorGrid") to change the color. Make sure you added jquery in your webresources.

Same way you can change color for the grid.

      <Name LocalizedName="contact" OriginalName="contact">contact</Name>
          <CustomAction Id="" Location="" Sequence="15">
              <Button Alt="$" Command="BackGroundColorView.Command" CommandType="General" Description="BackGroundColor" Id="" Image32by32="" Image16by16="" LabelText="" Sequence="15" TemplateAlias="o1" ToolTipTitle="" ToolTipDescription="" />
          <RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
          <CommandDefinition Id="BackGroundColorView.Command">
              <EnableRule Id="" />
            <DisplayRules />
            <Actions />
          <TabDisplayRules />
          <DisplayRules />
            <EnableRule Id="">
              <CustomRule FunctionName="BackGroundColorGrid" Library="$webresource:dns_contact" Default="false" InvertResult="false">
                <CrmParameter Value="SelectedControlAllItemReferences" />
                <CrmParameter Value="SelectedControl" />

javascript code>
BackGroundColorGrid (items, grid) {
    try {
        if (items) {
            //var index = $("#gridBodyTable").find("col[name=address1_addresstypecode]").index();

            //if (index != -1) {
                for (var i = 0; i < items.length; i++) {
                    var id = items[i].Id;
                    $(grid._element).find("tr[oid='" + id + "']").each(function () {
                        var theTr = $(this);
                        //console.log(i+ " - " + theTr.children('td').length)

                        //if (theTr.find("td").slice(index, index+1).text().toLowerCase().indexOf("Ship To") >= 0) {
                            theTr.find("td").css("background-color", "#FFFFFF");
    catch (e) {

MS Dynamics CRM 2011 - EnableRule, ValueRule, OrRule & CustomRule in Ribbon Customizations

MS Dynamics CRM 2011 - Ribbon Drop Down Menu

Customize the CRM Ribbon

No comments: