or
Hi,
I’m trying to add tabs control as client template (nested element inside grid) and hide some tabs based on the data in the grid using ajax binding.
I’m using boolean expression inside item().Visible([boolean expression here]) to determine whether or not show each tab. Even though Boolean expression is correct, Visible() method doesn't reflect it.
As an example I used Kendo Demo Project (Kendo.Mvc.Examples) /razor/web/grid/detailtemplate.cshtml page:
@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.EmployeeViewModel>() .Name("Employees") .Columns(columns => { columns.Bound(e => e.FirstName).Width(140); columns.Bound(e => e.LastName).Width(140); columns.Bound(e => e.Title).Width(200); columns.Bound(e => e.Country).Width(200); columns.Bound(e => e.City); }) .ClientDetailTemplateId("employeesTemplate") .Pageable() .DataSource(dataSource => dataSource .Ajax() .Read(read => read.Action("HierarchyBinding_Employees", "Grid")) .PageSize(5) ) .Sortable())<script id="employeesTemplate" type="text/kendo-tmpl"> @(Html.Kendo().TabStrip() .Name("TabStrip_#=EmployeeID#") .SelectedIndex(0) .Items(items => { items.Add().Text("Orders").Content(@<text> @(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.OrderViewModel>() .Name("Orders_#=EmployeeID#") .Columns(columns => { columns.Bound(o => o.OrderID).Width(101); columns.Bound(o => o.ShipCountry).Width(140); columns.Bound(o => o.ShipAddress).Width(200); columns.Bound(o => o.ShipName).Width(200); }) .DataSource(dataSource => dataSource .Ajax() .Read(read => read.Action("HierarchyBinding_Orders", "Grid", new { employeeID = "#=EmployeeID#" })) ) .Pageable() .Sortable() .ToClientTemplate()) </text> ); items.Add() .Visible("#= Country #" == "USA") .Text("Contact Information: #= Country #").Content( "<div class='employee-details'>" + "<ul>" + "<li><label>Country:</label>#= Country #</li>" + "<li><label>City:</label>#= City #</li>" + "<li><label>Address:</label>#= Address #</li>" + "<li><label>Home Phone:</label>#= HomePhone #</li>" + "</ul>" + "</div>" ); }) .ToClientTemplate())</script>$("#grid").kendoGrid({ dataSource: dataSource, filterable: true, sortable: { mode: "multiple", allowUnsort: true }, height: 400, pageable: true, selectable: "row", resizable: true, reorderable: true, columns: [ { field: "DocumentName", title: "Document Name", width: "150px" }, { field: "DocumentDescription", title: "Description", width: "150px" }, { field: "StateId", title: "State", width: "120px", editor: categoryDropDownEditor }, { field: "Policy_CertificateNumber", title: "Policy/Certificate Number", width: "170px" }, { field: "Amount", title: "Amount", format: "{0:c}", width: "110px" }, { field: "ExpiryDate", title: "Expiry Date", width: "110px", template: '#= kendo.toString(ExpiryDate,"M/d/yyyy")#' }, { command: [{ id: "View", name: "View", click: showDetails, template: "<a class='k-button k-button-icontext k-grid-View' href='' style='min-width:7px;'><input type='image' src='../../Content/Images/document.png' text='''/></a>" }, { id: "edit", name: "edit", template: "<a class='k-button k-grid-edit' href='' style='min-width:7px;'><span class='k-icon k-edit'></span></a>"}], title: " ", width: "92px" }], editable: "inline"});function categoryDropDownEditor(container, options) { $('<input data-text-field="StateName" data-value-field="StateId" data-bind="value:' + options.field + '"/>') .appendTo(container) .kendoDropDownList({ autoBind: false, dataTextField: "StateName", dataValueField: "StateId", dataSource: { type: "json", transport: { read: function (options) { $.ajax({ type: "GET", url: "Documents.aspx/GetStates", contentType: "application/json; charset=utf-8", dataType: "json", data: options.data, success: function (result) { var d = $.parseJSON(result.d); options.success(d); } }); } } } }); }var params ={"date": "2013-03-13T07:00:00.000Z","region":0,"pageNumber":1,"pageSize":10,"sortBy":0,"sortOrder":0};myDataSource.read(params),if (!that.options.serverPaging) { delete options.take; delete options.skip; delete options.page; delete options.pageSize;}public class IncomeChartModel{ public string Label { get; set; } public List<int> Year { get; set; } public List<int> Data { get; set; }}@{ var kendo = Html.Kendo().Chart(Model.IncomeChart); kendo.Title("Inkomen"); kendo.Name("IncomeChart"); kendo.CategoryAxis(axis => axis.Categories(model => model.Year)); kendo.SeriesDefaults(s => s.Area()); foreach (var item in Model.IncomeChart) { var myItem = item; kendo.Series(series => series.Area(model => myItem.Data).Name(myItem.Label)).AutoBind(true); } kendo.Render();}jQuery(function(){jQuery("#IncomeChart").kendoChart({"title":{"text":"Inkomen"},"series":[{"name":"AOW","type":"column","field":"myItem.Data"},{"name":"Brand New Day","type":"column","field":"myItem.Data"}],"categoryAxis":[{"categories":["System.Collections.Generic.List`1[System.Int32]","System.Collections.Generic.List`1[System.Int32]"]}],"dataSource":{"schema":{"model":{"fields":{"Label":{"type":"string"},"Year":{"type":"object"},"Data":{"type":"object"}}}},"data":[{"Label":"AOW","Year":[2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035,2036,2037,2038,2039,2040,2041,2042,2043,2044,2045,2046,2047,2048,2049,2050,2051,2052,2053,2054,2055,2056,2057,2058,2059,2060,2061,2062,2063,2064,2065,2066,2067,2068,2069,2070,2071,2072,2073,2074],"Data":[1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},{"Label":"Brand New Day","Year":[2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035,2036,2037,2038,2039,2040,2041,2042,2043,2044,2045,2046,2047,2048,2049,2050,2051,2052,2053,2054,2055,2056,2057,2058,2059,2060,2061,2062,2063,2064,2065,2066,2067,2068,2069,2070,2071,2072,2073,2074],"Data":[25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000]}]},"autoBind":true});});