0

私はデータテーブルを生成するためにprimeUIを使用しています。列のテキストをフォーマットしたい。以下は、primeUIデータテーブルをロードするための私のコードです。

$('#tbl').puidatatable({
        caption: 'Local Datasource',
        columns: [
            {field: 'legendText', headerText: 'Text'},
            {field: 'legendPercentage', headerText: '%age'},
            {field: 'legendValue', headerText: 'value'}
        ],
        datasource: responseData
    });

列のテキストをフォーマットしたい。誰でもこれで私を助けることができますか?値を通貨形式にしたい。このような 2 つの 10 進数形式の %age 列。

テキスト| %age |値|

abc | 30.00 |123,3|

4

1 に答える 1

2

その資料によると

http://www.primefaces.org/primeui/#datatable

content: 行データを受け取り、文字列または jQuery オブジェクトがセルをカスタマイズすることを期待する関数。

簡単に思えますが、

columns: [
{ field: 'vin', 
  content: function(rowData) { 
            console.log(rowData);
//format column data here, then return the formatted value
            return rowData.vin;
            },
  headerText: 'Vin'
},

{field: 'brand', headerText: 'Brand'},
{field: 'year', headerText: 'Year'},
{field: 'color', headerText: 'Color'}
]
于 2016-02-11T16:17:43.553 に答える