edit:
function
(e) {
if
(e.model.IsNotEditable) {
e.container.html( $(
'input'
, e.container).val());
}
}
var companyDataTransport = new kendo.data.RemoteTransport({
read: {
url: base_url + "/company",
dataType: "json",
type: "GET"
},
});
var dsCompany = new kendo.data.DataSource({
pageSize: 10,
serverPaging: true,
schema: {
type: "json",
model: Company
},
transport: companyDataTransport,
parameterMap: function (options) {
var parameters = {
max: options.pageSize,
page: options.page
}
return parameters;
},
});
function mobileServicersDataBind() {
$("#servicerView").kendoMobileListView({
dataSource: dsCompany,
template: kendo.template($('#servicerOnOffTemplate').html()),
endlessScroll: true,
scrollThreshold: 30
});
};
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);
}
});
}
}
}
});
}