0

How can I change the background color of a row using GridMvc? I've looked at the posting here:

Changing Background of GridMvc Column on Condition

I've tried using the SetRowCssClasses property (see below) but nothing happens. So, I don't know if I'm using it incorrectly or I need to do more than what I have in the below. Given that I'm relatively new to MVC and definitely new to GridMvc, it could be both. So, any help on what I need to change to get the rows where the bitTestOrderFlag is true to red is appreciated.

Thank you.

@Html.Grid(Model).SetRowCssClasses(i => i.bitTestOrderFlag ? "cssClassRed" : string.Empty).Columns(columns =>

{

columns.Add(c => c.intOrderNumber).Titled("Order Number")
.Encoded(false)
.Sanitized(false)
.SetWidth(30)
.RenderValueAs(o => Html.ActionLink(o.intOrderNumber.ToString(), "GetOrderDetails", "Orders", new { orderNumber = o.intOrderNumber }, null));

columns.Add(c => c.strCustomerNumber).Titled("Customer Number");

columns.Add(c => c.dtEntryDate).Titled("Entered Date").Format("{0:MM/dd/yyyy}");

columns.Add(c => c.strBillToName).Titled("BillTo Name");

columns.Add(c => c.strBillToStreetAddr).Titled("BillTo Street Address");

columns.Add(c => c.strBillToCity).Titled("BillTo City");

columns.Add(c => c.strShipToName).Titled("ShipTo Name");
   
columns.Add(c => c.strShipToStreetAddr).Titled("ShipTo Street Address");

columns.Add(c => c.strShipToCity).Titled("ShipTo City");

columns.Add(c => c.strPoNumber).Titled("PO Number");

columns.Add(c => c.bitTestOrderFlag).Titled("TestOrder");

}).WithPaging(8)

rsine
  • 91
  • 1
  • 7

1 Answers1

0

After trying unsuccessfully to add this to Site.css and GridMvc.css:

.cssClassRed
{
    background-color:red !important;
}

I ended up adding a new MyStyleSheet.css to the Content folder and placing the above in it. Then I updated the _Layout.cshtml adding to the head section the following:

<link href="@Url.Content("~/Content/MyStyleSheet.css")" rel="stylesheet" type="text/css" />

Once I did these two things, the rows were colored red as I needed. I'm not sure whether what I did was the correct way or the best way, but it worked. So, I thought I would share my solution in case others run into a similar issue as I was.

rsine
  • 91
  • 1
  • 7