Jquery 如何在kendoGrid中为双精度数字设置逗号

Jquery 如何在kendoGrid中为双精度数字设置逗号,jquery,kendo-ui,Jquery,Kendo Ui,我正在将数据库中的值绑定到kendoGrid。我想将逗号分隔符设置为网格中的所有列数(例如458690到4558690)。我在kendoui中阅读了数字格式概念,但没有足够的信息。我如何设置呢。这取决于您使用的文化,但基本上,您只需在列中添加一个字段格式,如下所示: 我创造了这个小提琴: 编辑: 似乎即使使用了正确的区域性,一些十进制字段在网格中也无法正确解释,因此我们无法应用自定义格式 为了解决这个问题,我们必须创建一个自定义解析器,以强制将字段视为十进制字段。我已经更新了我以前的小提琴:

我正在将数据库中的值绑定到kendoGrid。我想将逗号分隔符设置为网格中的所有列数(例如458690到4558690)。我在kendoui中阅读了数字格式概念,但没有足够的信息。我如何设置呢。

这取决于您使用的文化,但基本上,您只需在列中添加一个字段
格式
,如下所示:

我创造了这个小提琴:


编辑:

似乎即使使用了正确的区域性,一些十进制字段在网格中也无法正确解释,因此我们无法应用自定义格式

为了解决这个问题,我们必须创建一个自定义解析器,以强制将字段视为十进制字段。我已经更新了我以前的小提琴:

这是通过在
datasource.schema.parse
中添加一个解析器来实现的,该解析器将字符串转换为数字:

$("#kendoGridView").kendoGrid({
    width: 1500,
    dataSource: data.d,
    resizable: true,
    rowTemplate:
    height: 790,
    dataBound: dbGrid,
    selectable: true,
    columns: [
        // Here I have added the format field
        { title: 'Revenue', field: 'Revenue', width: '20%', sortable: true, format: "{0:c3}" },
        { title: 'postals', field: 'postals', width: '12%', sortable: true },
        { title: 'MQC', field: 'MQC', width: '12%', sortable: true },
    ]
});
您可以尝试使用该方法并将其与该方法相结合

e、 g


您可以使用大多数东西,该方法受C#方法的启发。

hello samuel,这个839009.378(双精度)值来自数据库。我编写了格式:{0:c3}用于列,但“,”分隔符不适用于这些值。这是代码行kendo.culture(“en-US”);或剑道文化(“德德”);必须填写。请给出回复。这似乎不是强制性的。。。但是我对格式做了一些修改,我看到他们的数据(我的小提琴依赖于剑道UI数据)包含一个带有十进制字段的列——运费——我们不能用上面提到的字段格式对其进行格式化。所以我更新了我的帖子以便添加另一个解决方案…我已经使用了行模板将图像绑定到网格。所以它不接受第二次。如果我对行模板(用于图像)进行注释,这很好…不可能对网格使用两行模板。?
$("#kendoGridView").kendoGrid({
    width: 1500,
    dataSource: data.d,
    resizable: true,
    rowTemplate:
    height: 790,
    dataBound: dbGrid,
    selectable: true,
    columns: [
        // Here I have added the format field
        { title: 'Revenue', field: 'Revenue', width: '20%', sortable: true, format: "{0:c3}" },
        { title: 'postals', field: 'postals', width: '12%', sortable: true },
        { title: 'MQC', field: 'MQC', width: '12%', sortable: true },
    ]
});
parse : function(data) {
    $.each(data.d.results, function(i, val) {
        // Here I convert the string in a decimal number
        val.Freight = +val.Freight;
    });
    return data;
}
 columns: [
     {
         field: "Salary",
         template: '#= kendo.format("{0:c}",Salary) #'
    }
 ]