PrimeUI 列文本格式
PrimeUI Column text formatting
我正在使用 primeUI 生成数据表。我想格式化列文本。下面是我加载 primeUI 数据表的代码。
$('#tbl').puidatatable({
caption: 'Local Datasource',
columns: [
{field: 'legendText', headerText: 'Text'},
{field: 'legendPercentage', headerText: '%age'},
{field: 'legendValue', headerText: 'value'}
],
datasource: responseData
});
我想格式化列文本。任何人都可以帮助我吗?我希望价值是货币格式。和 %age 列以这样的两位小数格式。
正文| %age |值|
abc | 30.00 |123,3|
根据它的文档
http://www.primefaces.org/primeui/#datatable
content: A function that takes row data and expects a string or a jQuery object to customize the cell.
看起来很简单,
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'}
]
我正在使用 primeUI 生成数据表。我想格式化列文本。下面是我加载 primeUI 数据表的代码。
$('#tbl').puidatatable({
caption: 'Local Datasource',
columns: [
{field: 'legendText', headerText: 'Text'},
{field: 'legendPercentage', headerText: '%age'},
{field: 'legendValue', headerText: 'value'}
],
datasource: responseData
});
我想格式化列文本。任何人都可以帮助我吗?我希望价值是货币格式。和 %age 列以这样的两位小数格式。
正文| %age |值|
abc | 30.00 |123,3|
根据它的文档
http://www.primefaces.org/primeui/#datatable
content: A function that takes row data and expects a string or a jQuery object to customize the cell.
看起来很简单,
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'}
]