首页 > 解决方案 > 更改图标/按钮列的格式

问题描述

关于这里的这个例子http://tabulator.info/docs/5.0/format#icon

在单元格单击功能中,如何更改格式化程序中使用的图标?

用例只是在单击单元格时将文件夹图标更改为文件夹打开。

标签: tabulator

解决方案


相当简单,在 rowData 中跟踪状态...

https://jsfiddle.net/hgwz4knp/

cellClick:function(e, cell){
   let row = cell.getRow();
   let data = row.getData();
   row.update({openClosed:data.openClosed ^ 1});
   this.redraw(true);
},
formatter:function(cell, fP, onR){
   let data = cell.getRow().getData();
   if (data.openClosed == 1) return "<i class='fas fa-folder-open'></i>";
   return "<i class='fas fa-folder'></i>";
},

推荐阅读