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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Conditional cell formating with date

Thread ID:

Created:

Updated:

Platform:

Replies:

129802 Apr 4,2017 01:07 PM UTC Apr 5,2017 06:20 AM UTC ASP.NET Web Forms 1
loading
Tags: Grid
GUYOT
Asked On April 4, 2017 01:07 PM UTC

Hello,

i am using your sample http://asp.syncfusion.com/demos/web/grid/conditionalformatting.aspx

How can i do to have celle with a date < now in formated with red text ?

Thank you !

Prasanna Kumar Viswanathan [Syncfusion]
Replied On April 5, 2017 06:20 AM UTC

Hi Guyot, 

Thanks for contacting Syncfusion support. 

To achieve your requirement, use queryCellInfo event of ejGrid. In this event we check the condition with the column and apply the css based on the mentioned condition.  

Find code example, screenshot and sample:  


<div> 
         <ej:Grid ID="FlatGrid" runat="server" AllowSorting="True" AllowPaging="True"> 
            <ClientSideEvents QueryCellInfo="formatingCell" /> 
            <Columns> 
                -------------------------------- 
                <ej:Column Field="OrderDate" HeaderText="Order Date" TextAlign="Right" Width="80" Format="{0:MM/dd/yyyy}" Priority="2" /> 
                ------------------------- 
            </Columns> 
        </ej:Grid> 
    </div> 
----------------------------------------- 

<script> 
    function formatingCell(args) { 
        if (args.column.field == "OrderDate") { 
            var date = args.data.OrderDate; 
            var currentDate = new Date(); 
            if (date < currentDate) { 
                $(args.cell).css("color", "red"); 
            } 
        } 
    } 
</script> 


Screenshot:  

 


Refer to the Help document for the queryCellInfo event.  


Regards, 
Prasanna Kumar N.S.V 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;