剑道网格中基于条件的列的值

时间:2018-02-09 11:00:33

标签: jquery asp.net-mvc kendo-ui kendo-grid

我使用下面的代码绑定一个kendo网格。

 $("#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来实现它。但它不起作用。

请帮忙,告诉我哪里弄错了。

提前谢谢。

1 个答案:

答案 0 :(得分:0)

我发现这是我自己:

,{
   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,
 }

谢谢你们..