dma*_*sen 6 javascript telerik kendo-ui kendo-grid
在此Kendo Grid演示中,如果您编辑"库存中的单位"下的数字并添加多个小数(尝试2.203848),则会将其截断为2.20.看起来这是默认行为.
我知道我们可以指定十进制格式{0:n4}
,例如.
但是如果小数位数未知或可以变化怎么办?有没有办法让网格使用用户输入的确切数字?
要使其在网格中工作,您需要使用自定义编辑器.将小数位数设置为足够高的数字,并确保您的字段格式有足够的位置.这个好的答案在这里调整了一下解决了你的问题.
function numberEditor(container, options) {
$('<input name="' + options.field + '"/>')
.appendTo(container)
.kendoNumericTextBox({
decimals: 8,
step : 0.01
});
}
$("#grid").kendoGrid({
dataSource: dataSource,
navigatable: true,
pageable: true,
height: 550,
toolbar: ["create", "save", "cancel"],
columns: [
"ProductName",
{ field: "UnitPrice", title: "Unit Price", format: "{0:c}", width: 120 },
{ field: "UnitsInStock", title: "Units In Stock", format: "{0:0.#########}", width: 120, editor: numberEditor },
{ field: "Discontinued", width: 120 },
{ command: "destroy", title: " ", width: 150 }],
editable: true
});
Run Code Online (Sandbox Code Playgroud)
});