JavaScript let toberemoved = [] cache.table.getColumnModel().getDatas().forEach((child,index) =>{ if(index < data.ca('columnWidths').length) { console.log(cache.table.getColumnModel().getDatas()) child.setWidth(data.ca('columnWidths')[index]); } if(index < nodeData.ca('columns').length){ let columnData = nodeData.ca('columns')[index] columnData.displayName && child.setDisplayName(nodeData.ca('showColumnIndex') ? index + ':' + columnData.displayName : columnData.displayName) child.setAlign(data.ca('centerAlign') ? 'center' : 'left'); //单元格字体及颜色 let defaultColor = nodeData.ca('tableTextColor')[1]; child.getLabelColor = (value, data, state)=>{ if(value){ //data.getId() == 2 && index == 1,指定某行某列的字体颜色! let cb = new Function('return ' + nodeData.ca('columnDataFunc'))() let ret = cb && cb(nodeData,data,child,index,value) let colortmp = ret ? ret : defaultColor; return colortmp; } else{ return defaultColor; } } }else{ //记录需要被移除的图元,注意不能直接在这里移除,会影响未完成的循环! toberemoved.push(child); } })
//根据标记移除图元 toberemoved.forEach((child,index)=>{ cache.table.getColumnModel().remove(child); }) |