如何在Kendo UI Grid的子网格中使用clientTemplate使用if条件?

时间:2018-09-10 16:15:30

标签: kendo-grid kendo-asp.net-mvc hierarchy client-templates

我正在使用clientTemplate在kendo UI网格层次结构的子网格中实现一些“ if condition ”。 使用clientTemplate的主网格,然后对我来说很好。但是,当我在Kendo UI Grid Hierarchy的子网格中使用相同的代码时,显示“无效模板” 参考链接 https://demos.telerik.com/kendo-ui/grid/hierarchy

 @(Html.Kendo().Grid(Model.OrderList)
                                            .Name("Grid")
                                            .Columns(columns =>
                                            {
                                                columns.Bound(p => p.OrderID).Width("50px").Sortable(false).Filterable(false).Title("<input type='checkbox' id='chkSelectAll' onchange='SelectAll();'/>").ClientTemplate("<input type='checkbox' id='orderselect_#=OrderID#' class='orderselect' value='#=OrderID#' onchange='chkOrUnchk(this)'/>");

                                            })
                                            .Resizable(r => r.Columns(true))
                                            //.Reorderable(r => r.Columns(true))
                                            .Selectable(selectable => selectable.Mode(GridSelectionMode.Multiple).Enabled(true))
                                            .Events(events => events.Change("Grid_OnRowSelect").DataBound("OrderGrid_OnDataBound").ColumnReorder("Grid_OnColumnReorder"))
                                            .Pageable(settings => settings.PageSizes(new int[] { 25, 50, 100, 500 }))
                                            .Sortable()
                                            .Scrollable(s => s.Virtual(false).Height("600px"))
                                            .Filterable()
                                            .ClientDetailTemplateId("childOrders")
                                            .DataSource(dataSource => dataSource
                                                        //.Server().Model(model => model.Id(p => p.OrderID))
                                                        .Ajax()
                                                        .PageSize(Model.DefaultOrderPageSize)
                                                        .Read(read => read.Action("ManageOrderLoadForGridAjax", "Order").Data("OrderSearchParameter"))
                                            )
                                        )

                                        <script id="childOrders" type="text/kendo-tmpl">
                                            @(Html.Kendo().Grid(new List<SMOrderNew>())
                                                .Name("grid_#=OrderID#") // template expression, to be evaluated in the master context
                                                .Columns(columns =>
                                                {
                                                    // *i want child order number but return parent order number using client template*
                                                    columns.Bound(p => p.OrderNumber).Groupable(false).Width("200px").Title("Order #").ClientTemplate("<a #if(DisplayDistribution){# class='OrderHover'#}# data-id='#= OrderID #' href='javascript:void(0);' style='float:left;' onclick='OpenOrderDetailsPopup(\"#= OrderID #\", 0);'> #=OrderNumber# </a>");
                                                    columns.Bound(p => p.BuyerUserID).Width("200px").Title("Buyer User ID").HtmlAttributes(new { style = "white-space: nowrap;" });
                                                })
                                                .Events(events => events.Change("Grid_OnRowSelect").DataBound("OrderGrid_OnDataBound").ColumnReorder("Grid_OnColumnReorder"))
                                                .DataSource(dataSource => dataSource
                                                    .Ajax()
                                                    .PageSize(100)
                                                    .Read(read => read.Action("ManageChildOrderLoadForGridAjax", "Order", new { OrderId = "#=OrderID#" }))
                                                )
                                                .Pageable()
                                                .Sortable()
                                                .ToClientTemplate()
                                            )
                                        </script>

0 个答案:

没有答案