我正在使用primeUI来生成数据表。我想格式化列文本。下面是我加载primeUI数据表的代码。
$('#tbl').puidatatable({
caption: 'Local Datasource',
columns: [
{field: 'legendText', headerText: 'Text'},
{field: 'legendPercentage', headerText: '%age'},
{field: 'legendValue', headerText: 'value'}
],
datasource: responseData
});
我想格式化列文本。任何人都可以帮助我吗?我希望价值是货币格式。和%age列以两个十进制格式,如下所示。
abc | 30.00 | 123,3 |
答案 0 :(得分: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'}
]