【问题标题】:PrimeUI Column text formattingPrimeUI 列文本格式
【发布时间】:2016-02-10 18:42:43
【问题描述】:

我正在使用 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|

【问题讨论】:

    标签: jquery prime-ui


    【解决方案1】:

    根据它的文件

    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-03-16
      • 2016-06-12
      • 2023-03-06
      • 1970-01-01
      • 2010-09-15
      • 1970-01-01
      • 1970-01-01
      • 2022-07-12
      • 2023-02-06
      相关资源
      最近更新 更多