我正在尝试将按钮添加到最后一列以进行onClick - >模态窗口。
按钮不会显示新列......
$(document)
.ready(function() {
//KendoGrid
var tabStrip;
var GridObject;
var expandedRowDataItem;
var accountInfoTabData;
var rowObject;
$("#grid")
.kendoGrid({
dataSource: {
transport: {
read: {
url: "/api/GridData/GetCustomers",
dataType: "json"
}
},
pageSize: 20,
schema: {
parse: function(response) {
$.each(response,
function(idx, elem) {
if (elem.RegistrationDate && typeof elem.RegistrationDate === "string") {
elem.RegistrationDate = kendo.parseDate(elem.RegistrationDate);
}
if (elem
.RemovalFromClientsDate &&
typeof elem.RemovalFromClientsDate === "string") {
elem.RemovalFromClientsDate = kendo.parseDate(elem.RemovalFromClientsDate);
}
});
return response;
}
}
},
autoBind: true,
height: 550,
filterable: true,
groupable: true,
sortable: true,
//editable: "inline",
pageable: {
refresh: true,
pageSizes: true,
buttonCount: 5
},
detailTemplate: kendo.template($("#template").html()),
detailInit: detailInit,
detailExpand: function(e) {
//this.collapseRow(this.tbody.find(" > tr.k-master-row").not(e.masterRow));
expandedRowDataItem = this.dataItem(e.masterRow);
}
},
{
columns: [
{ field: "UniqueClientCode", title: "Уникальный код клиента" },
{ field: "ClientName", title: "Имя клиента" },
{ field: "ClientOKPO", title: "ОКПО клиента" },
{
field: "RegistrationDate",
title: "Дата регистрации",
type: "date",
format: "{0:dd/MM/yyyy}"
},
{
field: "RemovalFromClientsDate",
title: "Дата удаления из клиентов",
type: "date"
},
{
command: { text: "View Details", click: showDetails },
title: "View DT",
width: "50px"
}
]
});
function showDetails(e) {
alert("view");
}
答案 0 :(得分:0)
在列定义的最后作为最后一列尝试此操作 编辑:(剃刀):
columns.Template(p => { }).ClientTemplate("<button style='width: 20px;'><i class='fa fa-pencil-square-o' aria-hidden='true'></i></button> <button style='width: 20px;'><i class='fa fa-trash' aria-hidden='true'></i></button>").Width(130).Title("Edit/Delete").HtmlAttributes(new { @class = "tdCenter" });
答案 1 :(得分:0)
很抱歉设置此问题。问题已经发现......那件事是如此愚蠢......&#34;括号&#34;。
列部分位于单独的括号中:
{
columns: [
/*some code*/
]
}
不知怎的,除了带按钮的最后一栏,它对整个网格起作用。
它应该是这样的:
$("#grid")
.kendoGrid({
dataSource: {
/*DataSource*/
},
columns: [ /*some code*/
]
});