- Home
- Forum
- ASP.NET MVC
- Conditional formatting Rows
Conditional formatting Rows
Thanks for using Syncfusion Products.
Your requirement is achieved by using the “QueryCellInfo” events in Grid. Please find the sample and code snippet.
Sample: conditionalformatting.zip
@(Html.EJ().Grid<MvcApplication122.Models.Order>("FlatGrid") .Datasource((IEnumerable<object>)ViewBag.datasource) .AllowPaging() . . . . . .ClientSideEvents(eve=>eve.QueryCellInfo("querycellinfo")) ) <script> function querycellinfo(args) { if (args.column.field == "OrderID" && args.data.OrderID >= 10251 && args.data.OrderID <= 10260) $($(args.cell).parent()).css("backgroundColor", "blue");/*custom css applied to the row */ if (args.column.field == "OrderID" && args.data.OrderID >= 10261 && args.data.OrderID <= 10270) $($(args.cell).parent()).css("backgroundColor", "white");/*custom css applied to the row */ if (args.column.field == "OrderID" && args.data.OrderID > 10270) $($(args.cell).parent()).css("backgroundColor", "gray");/*custom css applied to the row */ } |
In querycell info event, we have applied the background color to the rows depends on the column values by using css style properties. Please find the knowledge base documentation for more information.
Documentation: http://www.syncfusion.com/kb/2979/how-to-select-or-highlight-rows-based-on-data
Please let us know if you have any queries.
Regards,
Balaji Marimuthu
Thanks for the update.
Please get back to us if you need any further assistance.
Regards,
Balaji Marimuthu
How would you use the colours from the Bootstrap CSS. Succes, etc.... ?
Hi is this possible to achieve with .NET Core 2?
Edit: Nevermind, I figured it out using rowDataBound as described here: https://www.syncfusion.com/forums/132334/change-background-colour-of-a-row-based-on-value-of-a-field
:)
Thanks
- 7 Replies
- 6 Participants
-
YN Yosvany Noda
- Apr 8, 2015 01:56 PM UTC
- Sep 27, 2017 05:49 AM UTC