我需要能够正确比较 Kendo HTML Grid 的客户端模板中的两个日期。这是我所拥有的:
@(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); ...
其中@CurDate 是视图中的一个变量:
String CurDate = DateTime.Now.ToShortDateString();
当我运行它时,CurDate 是正确的。但是当然比较不能正常工作,因为 DueDate 的格式不同。我怎样才能使这项工作?