【问题标题】:How to wrap text in ag-grid from a checkbox如何从复选框中将文本包装在 ag-grid 中
【发布时间】:2021-11-05 09:48:16
【问题描述】:

我正在使用 ag-grid 角度组件,需要一个功能来将文本包装在需要通过复选框控制的单元格中。

【问题讨论】:

    标签: ag-grid


    【解决方案1】:

    只需将cellClassRules 添加到列:-

     cellClassRules: {
          'wrap-text': params => {
            return params.data.checkboxColumn === true;
          },
         'no-wrap-text': params => {
            return !params.data.checkboxColumn;
          }
        },
    

    或者,复选框在外面

    1. 将信息存储在数组中

      this.checkBoxInfo = []; // 使用 api.refreshCells({force:true})

       cellClassRules: {
            'wrap-text': params => {
                // add condition using `this.checkBoxInfo` and return 
                                 //   true/false
                  return  true/false;
              },
          'no-wrap-text': params => {
                  // add condition using `this.checkBoxInfo` and return 
                 //   true/false
                  return  true/false;
             }
         },
      

    【讨论】:

    • 它适用于所有行和列,并且复选框超出了 ag-grid。
    • 已更新...您需要将条件信息存储在数组中。
    猜你喜欢
    • 2019-01-22
    • 2018-09-18
    • 2018-05-19
    • 2020-10-27
    • 2018-05-20
    • 2020-12-02
    • 2021-12-17
    • 1970-01-01
    • 2016-01-21
    相关资源
    最近更新 更多