We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Conditional Formatting - Entire row, based in one specific field

Hi,

I have a field with three possible values : 
0 - Not checked
1 - Approved
2 - Not approved

I want to change the entire row color base on this values, like this:
0 - Default
1 - Green
2 - Red

I searched, but again I didn't found anything in the online documentation.

Is there a way to do this?
If the answer is yes, I always prefer server-side events code, send-me a solution in javacript only if there is not a solution for the server-side code.

Thanks again, you guys are awesome.

Regards

Henrique

1 Reply

BM Balaji Marimuthu Syncfusion Team May 4, 2015 10:28 AM UTC

Hi Marcelo,

Thanks for using Syncfusion Products.

We have analyzed and a created sample for your requirement. Please find the sample and the code snippet.
Sample: Sample.zip

<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">


<div>

<ej:Grid ID="Grid" runat='server' AllowPaging="true" >

<ClientSideEvents QueryCellInfo="querycellinfo" />

</ej:Grid>

</div>

</asp:Content>


<asp:Content runat="server" ID="Content1" ContentPlaceHolderID="ScriptSection">

<script>

function querycellinfo(args) {

if (args.column.field == "Number" && args.data.Number == 1)

$($(args.cell).parent()).css("backgroundColor", "Green");/*custom css applied to the row */

if (args.column.field == "Number" && args.data.Number == 2)

$($(args.cell).parent()).css("backgroundColor", "Red");/*custom css applied to the row */

}

</script>
</asp:Content>



We would like to let you know that we can’t apply the background color to the row base on the values in server side. But we can change the rows background color based on the values by using “QueryCellInfo” client side event. So we suggest you to use the client side event “QueryCellInfo” to achieve your requirement.

Please refer the online documentation for further details.
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

Loader.
Live Chat Icon For mobile
Up arrow icon