本文体验datagrid单元格的格式化和样式化。

  datagrid显示的DOM结构

<td field="code">
    <div style="text-align:left" class="datagrid-cell datagrid-cell-c1-code">
         文字
    </div>
</td>

field属性对应字段.
div中的内容对应单元格内容。

  formatter的用法

field: 'UserStatus', title: '状态', formatter: function (value, row, index) {
    if (value == "0") {
        return '启用';
    } else {
        return '禁用';
   }
              
□ 日期格式化

field: 'SubTime', title: '注册时间', formatter: function (value, row, index) {
    return eval("new " + value.substr(1, value.length - 2)).toLocaleDateString();
}

  styler的用法

styler: function(value, row, index){
    if (value == "1") {
        return 'background-color:red;';
    }
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-14
  • 2022-12-23
  • 2021-11-01
  • 2022-12-23
猜你喜欢
  • 2021-10-04
  • 2022-12-23
  • 2021-09-17
  • 2021-09-23
  • 2021-08-16
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案