4
$("#kendoGridView").kendoGrid({
                            width: 1500,
                            dataSource: data.d,
                            resizable: true,
                            rowTemplate:
                            height: 790,
                            dataBound: dbGrid,
                            selectable: true,
                            columns: [
                                            { title: 'Revenue', field: 'Revenue', width: '20%', sortable: true },
                                            { title: 'postals', field: 'postals', width: '12%', sortable: true },
                                            { title: 'MQC', field: 'MQC', width: '12%', sortable: true },
                                      ]
                        });

データベースからkendoGridに値をバインドしています。グリッド内のすべての列番号にコンマ区切り文字を設定したい(例:458690から4,58,690)。kendouiのNumberFormatingの概念を読みましたが、十分な情報がありません。どうすればよいですか。セットする。

4

2 に答える 2

4

使用しているカルチャによって異なりますが、基本的には、ドキュメントformatに従ってフィールドを列に追加する必要があります。

$("#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 },
    ]
});

私はこのフィドルを作成しました:http://jsfiddle.net/AHCbq/


編集 :

正しいカルチャを使用しても、一部の小数フィールドがグリッドで正しく解釈されず、カスタム形式を適用できないようです。

この問題を回避するには、フィールドを10進フィールドとして表示するように強制するために、カスタムパーサーを作成する必要があります。以前のフィドルを更新しました:http://jsfiddle.net/AHCbq/7/

datasource.schema.parseこれは、文字列を数値に変換するパーサーを追加することで実現されます。

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;
}
于 2012-12-10T10:30:59.017 に答える
0

列にテンプレートを使用して、それをkendo.formatメソッドと組み合わせることができます。

例えば

 columns: [
     {
         field: "Salary",
         template: '#= kendo.format("{0:c}",Salary) #'
    }
 ]

ここではほとんどのものを使用できます。このメソッドはC#メソッドに触発されています。

于 2012-12-10T22:51:54.600 に答える