Kendo Grid numbers are truncated to 2 decimal places. How to make him respect what the user entered?

In this Kendo Grid demo , if you edit the numbers under “Units in Stock” and add a few decimal places (try 2.203848) lc truncates it to 2.20. This seems to be the default behavior.

And I know that we can specify a decimal format with {0:n4}, for example.

But what if the number of decimal places is unknown or may vary? Is there a way to make the grid an exact number that the user enters?

+4
source share
2 answers

, . , . .

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: "&nbsp;", width: 150 }],
    editable: true
});

});

+4

kendo ui , kendo.format(). .

, ,

{0:$###,###,###,###,###,###,###,###.##############} 

, .

0

All Articles