我正在使用以下代码绑定剑道网格。
$("#dvToInvoice").kendoGrid({
dataSource: {
autoBind: false,
transport: {
read: url
},
schema: {
data: "Data",
total: "Total",
errors: "Errors",
model: {
fields: {
OrgRule: { type: "string" }
}
}
},
pageSize: 15,
serverPaging: false,
},
pageable: {
pageSize: 15,
info: true,
refresh: false
},
columnMenu: true,
onetouch: true,
sortable: true,
scrollable: true,
filterable: {
extra: false
},
// resizable: true,
columns: [
{
field: "eventname",
title: "Title"
},
{
field: "eventdate",
title: "Date",
template: "#= kendo.toString(kendo.parseDate(eventdate, 'dd-MMM-yyyy'), 'dd-MMM-yyyy') #",
width: 110,
},
{
field: "location",
title: "Location"
},
{
field: "teamevent",
title: "Team Event",
width: 130,
},
{
field: "onlineregopen",
title: "Online Reg Open",
width: 170,
},
{
field: "onlineclosingdate",
title: "online closing date",
template: "#= kendo.toString(kendo.parseDate(onlineclosingdate, 'dd-MMM-yyyy'), 'dd-MMM-yyyy') #",
width: 180
},
{
title: "Action",
template: "<a id='btnTeams#= eventid #' href='Index?eventid=#= eventid #'>Teams</a>",
// template: "#=if(onlineregopen == 'true'){true}else{false}#",
width: 70,
}
],
pageable: {
pageSizes: [15, 50, 75, 100]
}
});
在“操作”列中,我要尝试实现的是,如果eventdate大于今天,则将启用锚链接(如果未禁用)。我试图通过添加if来实现它。但它不起作用。
请帮助,并告诉我在哪里出错。
提前致谢。
最佳答案
我发现了我自己:
,{
title: "Action",
template: '#if(onlineregopen == true) {# <a id="btnTeams#= eventid # href="Index?eventid=#= eventid #">Teams</a> # } else {# <a id="btnTeams#= eventid #" href="javascript:javascript(0);">Teams</a> #}#',
width: 70,
}
谢谢你们..