我有一个带内联编辑的剑道网格。现在,在一列中,我想添加一个剑道色选择器。当行不在编辑模式时,我如何添加它并显示选定的颜色?
有人能给我举个例子吗?在剑道格子里有颜色选择器吗?
谢谢
发布于 2014-05-26 21:02:11
正如@dfsq所说,你必须使用一个单元格模板来显示颜色。此外,您还需要为columns.editor
定义一个ColorPicker
。
模板的代码是一个函数,它生成一个div
,其背景颜色是来自网格的color
值:
template: function(dataItem) {
return "<div style='background-color: " + dataItem.Color + ";'> </div>";
},
对于editor
,应该将一个函数定义为:
editor : function (container, options) {
// create an input element
var input = $("<input/>");
// set its name to the field to which the column is bound ('name' in this case)
input.attr("name", options.field);
// append it to the container
input.appendTo(container);
// initialize a Kendo UI ColorPicker
input.kendoColorPicker({
value: options.model.Color,
buttons: false
});
}
您可以在这里看到一个例子:http://jsfiddle.net/OnaBai/6XJV6/
https://stackoverflow.com/questions/23875627
复制相似问题