Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
460
Different date formats and conditional color coding
posted

Hi Infragistics,

I am trying to create a grid with a date column that can be conditionally colored depending on a user date format setting. I am currently defining the column's conditional with a template and it works fine for most date formats. However for three particular date formats the conditions from the template are not applied. 

This is an example of the template with conditions:

{{if new Date(${fldDate}.replace(/-/g, '/')).setHours(0,0,0,0)>=new Date(1262304000000).setHours(0,0,0,0) && new Date(${fldDate}.replace(/-/g, '/')).setHours(0,0,0,0)<=new Date(1293840000000).setHours(0,0,0,0)}}<div style="height:100%;background-color:Red;">${fldDate}</div>

{{elseif new Date(${fldDate}.replace(/-/g, '/')).setHours(0,0,0,0)>=new Date(1293926400000).setHours(0,0,0,0) && new Date(${fldDate}.replace(/-/g, '/')).setHours(0,0,0,0)<=new Date(1325376000000).setHours(0,0,0,0)}}<div style="height:100%;background-color:LawnGreen;">${fldDate}</div>

{{elseif new Date(${fldDate}.replace(/-/g, '/')).setHours(0,0,0,0)>=new Date(1325462400000).setHours(0,0,0,0)}}<div style="height:100%;background-color:Aqua;">${fldDate}</div>

{{else}}<div style="height:100%;background-color:Transparent;">${fldDate}</div>{{/if}}

Here we have three conditions. Two with closed interval, one with an open interval, and then a final statement if no of the three conditions match.

This template works fine for most of the date formats I have tried except for:

- dd-MMM-yyyy

- dd-MMM-yy

- dd/MMM/yyyy

 Any ideas?

The following date formats work just fine:

- yyyy-MMM-dd

- yyyy-MM-dd

- dd-MM-yyyy

- yyyy/MMM/dd

- yyyy/MM/dd

- dd/MM/yyyy

 

 

 

 

 

 

 

Best Regards

Fredrik