Hi Edgar,
Thanks for contacting Syncfusion support.
By default, we have the queryCellInfo event in ejGrid which have an option to apply our own custom logics to cell formatting and text corrections. It will trigger for every cell in Grid with complete information about cell and arguments for transforming particular cell.
Please refer to the below online document link for queryCellInfo event,
http://help.syncfusion.com/js/api/ejgrid#events:querycellinfo
Please find the below Knowledge Base documentation for your requirement,
https://www.syncfusion.com/kb/4886/how-to-add-a-custom-command-with-server-side-event-handling
We have an online sample for conditional formatting to cell and refer to the below links,
http://asp.syncfusion.com/demos/web/grid/conditionalformatting.aspx
If we misunderstood your requirement, please get back to with additional information.
Regards,
Saravanan.A
Hi Edgar,
In queryCellInfo event we can get the row data in the arguments. Using that we need to check the condition with headerText and compare the dates of the two column. If the Orderdate column is greater than CustomerID column, then the OrderDate column will be colored with green. If it is less than the CustomerID column then it will be colored with brown.
Please find the following code example, screenshot and sample
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent"> <ej:Grid ID="Grid" runat="server" AllowPaging="true" AllowSorting="true"> <ClientSideEvents QueryCellInfo="formatingCell" /> <FilterSettings FilterType="Menu"></FilterSettings> <Columns> <ej:Column Field="OrderID" HeaderText="Order ID" IsPrimaryKey="True" TextAlign="Right" Width="75" /> <ej:Column Field="CustomerID" HeaderText="Date" Width="80" Format="{0:MM/dd/yyyy}" /> <ej:Column Field="EmployeeID" HeaderText="Employee ID" TextAlign="Right" Width="75" /> <ej:Column Field="Freight" HeaderText="Freight" TextAlign="Right" Width="75" Format="{0:C}" /> <ej:Column Field="OrderDate" HeaderText="Order Date" TextAlign="Right" Width="80" Format="{0:MM/dd/yyyy}"/> <ej:Column Field="ShipCity" HeaderText="Ship City" Width="110" /> </Columns> </ej:Grid> <script type="text/javascript"> function formatingCell(args) { var $element = $(args.cell); if (args.column.headerText == "Order Date") { if (args.data.CustomerID < args.data.OrderDate) $element.css("background-color", "#336c12").css("color", "white"); else $element.css("background-color", "#7b2b1d").css("color", "white"); } } </script> |
Screenshot:
Sample Link: http://www.syncfusion.com/downloads/support/directtrac/144482/ze/Sample-673478118
Regards,
Saravanan.A