ag-grid-vue表格的一些问题总结(一)

Summer ·
更新时间:2024-09-21
· 777 次阅读

ag-grid-vue表格的一些问题总结 1.表头居中和表格内容居中

找了很多资料也没有找到
没居中之前
居中之后
在style标签中输入下面代码,就会居中。

/deep/ .ag-theme-balham [class^='ag-'], .ag-theme-balham [class^='ag-']:focus, .ag-theme-balham [class^='ag-']:after, .ag-theme-balham [class^='ag-']:before { text-align: center; } /deep/ .ag-header-cell-text{ text-align: center ; width: 100%; } 2.根据条件将单元格内容加背景字体加颜色cellStyle

初始样式
改变后样式
第一张图到第二张图只需要在对应的定义字段的位置添加下面的代码

{ headerName: '最新文件上传人员', field: 'UploadPersonnel', tooltipField: 'UploadPersonnel', sortable: true, cellStyle: function (params) { return { color: params.value === '鲁迅' ? '#88d068' : '#ff3366', background: params.value === '朱自清' ? '#88d068' : '#ff3366' } } } 3.给表格加操作栏cellRendererFramework

操作栏
加操作栏需要在字段定义的时候写如下代码:

{ headerName: '操作', cellRendererFramework: Vue.extend(ActionDown), sortable: true },

如果把操作栏固定在左侧或者右侧需要加:

{
headerName: ‘操作’,
cellRendererFramework: Vue.extend(ActionDown),
sortable: true,
pinned: ‘right’,
},

ActionDown是具体的操作需要引入ActionDown中的内容为:

export default { methods: { downLoad () { this.params.context.componentParent.todownLoad(this.params.node.data, this.params.node.rowIndex) }, queryHistory () { this.params.context.componentParent.toqueryHistory(this.params.node.data, this.params.node.rowIndex) } }, computed: {}, watch: { params: { handler: function (newVal, oldVal) { this.enable = newVal.data.enable }, immediate: true } } }
作者:一只成长的程序猿



VUE grid

需要 登录 后方可回复, 如果你还没有账号请 注册新账号