<EjsGrid DataSource="@Orders" AllowFiltering="true" Height="315">
<GridFilterSettings Type="FilterType.Menu"></GridFilterSettings>
<GridEvents QueryCellInfo="CellInfoHandler" TValue="Order"></GridEvents>
<GridColumns>
. . . . . . . . .. . . . . .
</GridColumns>
</EjsGrid>
<style>
.currentweek{
background-color: green;
}
.previousweek{
background-color:yellow;
}
.previousmonth{
background-color: red;
}
</style>
@code{
public List<Order> Orders { get; set; }
public void CellInfoHandler(QueryCellInfoEventArgs<Order> Args)
{
if (Args.Column.Field == "OrderDate") {
if ( Args.Data.OrderDate < DateTime.Now.AddDays(-20))
{
Args.Cell.AddClass(new string[] { "previousmonth" });
}
else if (Args.Data.OrderDate < DateTime.Now.AddDays(-10))
{
Args.Cell.AddClass(new string[] { "previousweek" });
}
else
{
Args.Cell.AddClass(new string[] { "currentweek" });
}
}
} |