I need to be able to properly compare two dates within the client template of a Kendo HTML Grid. Here is what I have:
@(Html.Kendo().Grid<TfInvoicesReturnModel>()
.Name("invoiceGrid")
.DataSource(dataSource => dataSource
.Ajax()
.Sort(sort => sort.Add("OrderDate").Descending())
.Read(read => read.Action("Invoices_Read", "Jobs", new { JobNo = Model.JobNo, CustomerNo = Model.CustomerId }))
.Events(events => events.Error("error_handler"))
.Model(model =>
{
model.Id(p => p.InvoiceNo);
})
)
.Columns(columns =>
{
columns.Bound(p => p.InvoiceNo).ClientTemplate(
"#if(BalanceDue > 0 && DueDate < " + @CurDate + ") {# " +
"<span style='color:red; font-weight:bold'>#: InvoiceNo #</span>" +
"#} else {#" +
"#: InvoiceNo #" +
"#} #"
).Title("Invoice").Width(125); ...
Where @CurDate is a variable in the view:
String CurDate = DateTime.Now.ToShortDateString();
When I run this, CurDate is correct. But of course the comparison is not working correctly because DueDate is not in the same format. How can I make this work?