我使用剑道ui与NumericTextBox
的可编辑网格。通常在NumericTextBox
中,小数点被限制为两位,即,如果我输入10.135,该值将被格式化为10.14。但我需要的是10.135本身。这里要做什么?
我的模型定义
var GridViewModel = new kendo.data.Model.define({
fields: {
Name: { type: "string", editable: false },
Weight: { type: "number", editable: true, validation: { required: true } },
}
});
,在我的视图模型中,我将网格设置为。
$("#DryingBinItemsAddedGrid").kendoGrid({
dataSource: {
data: DataDetails,
schema: {
model: GridViewModel
},
},
editable: true,
dataBound: function () {
},
columns: [
{
field: "Name",
title: "Name"
},
{
field: "Weight",
title: "Total Weight"
}
]
});
在这个例子中我没有提到我失败的尝试。目前我的Weight
字段是一个数字文本框与两个字段。这里要做的是使我的Weight
字段具有3小数点的NumericTextBox。
为了控制NumericTextBox作为编辑器使用的配置,您需要实现一个自定义编辑器,否则,将使用NumericTextBox的默认配置(小数点后2位)。
尝试更改您的"Weight"列定义为:
{
field: "Weight",
title: "Total Weight",
editor: weightEditor
}
并添加一个实现自定义编辑器的weightEditor函数:
function weightEditor(container, options) {
$('<input name="' + options.field + '"/>')
.appendTo(container)
.kendoNumericTextBox({
decimals: 3,
})
};
演示:http://dojo.telerik.com/@Stephen/uviLO