0

我正在使用带有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 } },
    }
});

在我的视图模型中,我将 Grid 设置为。

$("#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。

4

1 回答 1

1

为了控制网格作为编辑器使用的 NumericTextBox 的配置,需要实现自定义编辑器,否则将使用 NumericTextBox 的默认配置(即 2 位小数)。

尝试将“重量”列定义更改为:

{
    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

于 2016-11-04T13:28:42.847 回答