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

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中的内容为:

<template>
  <div style="float:left;">
    <a
      style="cursor: pointer;color:#0A56C9;padding-right:10px"
      @click="downLoad()"
    >下载
    </a>

    <a
      style="cursor: pointer;color:#0A56C9"
      @click="queryHistory()"
    >查看历史版本
    </a>
  </div>
</template>

<script>
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
    }
  }
}

</script>

<style lang="css" scoped>

</style>
  • 5
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一只成长的程序猿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值