当前位置: 首页 > news >正文

谷神前端组件增强:自定义列

初始化
$gp.customColumn = {}
initColumnPool
/*** initColumnPool* 初始化列池* * @param prefix 前缀* @param length 长度* * @return Array 列ID数组* */
function initColumnPool (prefix, length) {return Array.from({length}, (value, index) => prefix + index)
}
selfPage.initColumnPool = initColumnPool
getColDef
/*** getColDef* 获取列定义* * @param detailTable 子列表* @param columnPool 列池* @param all 是否全部拉取* * @return Array 列定义* */
function getColDef (detailTable, columnPool, all) {return detailTable.getAllColumns().filter(colunm => columnPool.includes(colunm.colDef.field)).map(column => {let {colDef: {field, headerName}, visible} = columnreturn {FIELD: field,HEADER_NAME: visible ? headerName : undefined,}}).filter(({HEADER_NAME}) => HEADER_NAME || all)
}
selfPage.getColDef = getColDef
mapColDef
/*** mapColDef* 映射列定义* * @param colDef 列定义* * @return Array 列定义* */
function mapColDef (colDef) {return colDef.map(({FIELD, HEADER_NAME}) => ({FIELD, HEADER_NAME}))
}
selfPage.mapColDef = mapColDef
newColumn
/*** newColumn* 新增列* * @param colDef 列定义* @param columnPool 列池* * @return String 新列ID* */
function newColumn (colDef, columnPool) {let fields = colDef.map(item => item.FIELD)let pool = columnPool.filter(column => !fields.includes(column))if (pool.length > 0) {return pool[0]} else {return null}
}
selfPage.newColumn = newColumn
renderColumn
/*** renderColumn* 渲染列* * @param detailTable 子列表* @param columnPool 列池* @param colDef 列定义* * @return void* */
function renderColumn (detailTable, columnPool, colDef) {if (!colDef) {return}if (typeof colDef == 'string') {colDef = JSON.parse(colDef)}if (Array.isArray(colDef)) {// 处理未定义的列let fields = colDef.map(item => item.FIELD)columnPool.forEach(column => {if (!fields.includes(column)) {detailTable.setColumnVisible(false)detailTable.getData().forEach((value, index) => {detailTable.setDataValue(index, column, null)})}})// 处理已定义的列colDef.forEach(({FIELD,HEADER_NAME,IS_NEW}) => {detailTable.setHeaderTitle(FIELD, HEADER_NAME)detailTable.setColumnVisible(FIELD, !!HEADER_NAME)if (!HEADER_NAME || IS_NEW) {detailTable.getData().forEach((value, index) => {detailTable.setDataValue(index, FIELD, null)})}detailTable.autoSizeColumn(FIELD)})} else {console.error('自定义列数据类型不正确!')}
}
selfPage.renderColumn = renderColumn
http://www.lryc.cn/news/359264.html

相关文章:

  • 31-ESP32-S3-WIFI篇-02 Event Group (事件标记组)
  • 构建企业级AI私有知识库
  • C语言王国——杨氏矩阵
  • 陪玩小程序都需要怎么做?
  • postgressql——子事务可见性判断 性能问题(8)
  • 20240531在飞凌的OK3588-C开发板上跑原厂的Buildroot测试USB摄像头
  • 从0开始学统计-什么是回归?
  • Element-ui使用上传时弹框选择文件类型
  • 原生小程序一键获取手机号
  • ARM虚拟机安装OMV
  • 【协议开发系列】梳理关于TCP和UDP两种协议的区别和使用场景
  • vue blob实现自定义多sheet数据导出到excel文件
  • Python—面向对象小解(3)
  • Nginx超时时间
  • Imgs,GT,Edge,Gradient_all,Gradient_Foreground
  • 自学成才Flutter 弹性布局、线性布局
  • Part 3.1 深度优先搜索
  • 前端Vue小兔鲜儿电商项目实战Day03
  • ORACLE 查询SQL优化
  • Ansible03-Ansible Playbook剧本详解
  • Qt-qrencode生成二维码
  • 长安链使用Golang编写智能合约教程(三)
  • Vercel deploy- Nextjs project error-URL link-env variable
  • Java | Leetcode Java题解之第123题买卖股票的最佳时机III
  • Ubuntu22.04之扩展并挂载4T硬盘(二百三十三)
  • Redis实现延迟队列
  • 如何准确查找论文数据库?
  • 翻译《The Old New Thing》- What a drag: Dragging a virtual file (IStream edition)
  • 【FPGA】Verilog语言从零到精通
  • unity打包的WebGL部署到IIS问题