【发布时间】:2015-07-16 10:47:42
【问题描述】:
我们可以在描述网格列的同时在列内添加 if 条件吗?这段代码有什么问题
如果文本长度超过 40char,我想在一列下的网格中显示一个按钮。
如果内容/数据小于 40 字符,我试图设置一个 if 条件,然后显示内容,否则显示一个按钮,单击按钮打开一个弹出窗口以显示该弹出窗口内的完整内容?
我们如何才能有条件地放置命令来显示按钮?
这是我的代码
columns: [{
field: "id",
title: "ID",
width: "100px"
}, // fields in the grid
{
field: "name",
title: "Name",
width: "100px"
}, {
field: "remarks",
title: "Remarks",
width: "160px", // under this column button will be displayed in each
var length = 40;
if (data.remarks.length > length) { //here this condition seems to be wrong, is there any other way to display the button for this condition
command: {
name: "remarks",
text: "Remarks",
click: function (e) {
var tr = $(e.target).closest("tr");
var data = this.dataItem(tr);
var win = $('#remarksWindow');
win.html(data.remarks);
if (!win.data('kendoWindow')) {
win.kendoWindow({
width: '600px',
height: '200px',
title: 'Remarks',
actions: ['Close']
});
}
win.parent().css({
top: e.pageY - 50,
left: e.clientX - 640,
width: '600px',
height: '200px'
});
win.data('kendoWindow').open(); // open the pop-up which contains the data
return false;
}
}
}
}
},
【问题讨论】:
标签: kendo-ui kendo-grid