【问题标题】:Not able to change icon in Ag-grid无法更改 Ag-grid 中的图标
【发布时间】:2020-11-24 12:08:16
【问题描述】:

我在角度使用 ag-grid 表并尝试更改其中的 aerrow 图标但它不起作用我在下面的代码中使用过但它不起作用

我正在更改列定义中的图标

public columnDefs = [
    { 
      headerName: "Group",
      field: 'group',
      cellRenderer: 'agGroupCellRenderer',
      icons: {
          groupContracted: '<img src="https://raw.githubusercontent.com/ag-grid/ag-grid/master/grid-packages/ag-grid-docs/src/javascript-grid-icons/minus.png" style="height: 12px; width: 12px;padding-right: 2px"/>',
        },
 
    },
    { headerName: "Year", field: "year" , sortable: true},
    { headerName: "Country", field: "country" }
  ];

但这没有被反映。我指的是下面的文档链接

https://www.ag-grid.com/javascript-grid-icons/

下面是 stackblitz 链接 https://stackblitz.com/edit/angular-ag-grid-tree-data-bbbcyb

【问题讨论】:

    标签: angular ag-grid


    【解决方案1】:

    Give icons 对象到 gridOptions 它将起作用

    public gridOptions = {
        rowSelection: 'multiple',
        groupSelectsChildren: true,
        groupSelectsFiltered: true,
        suppressAggFuncInHeader: true,
        suppressRowClickSelection: true,
         autoGroupColumnDef: {headerName: "Athlete", field: "athlete", width: 200,
            cellRenderer:'agGroupCellRenderer'
        },
        getNodeChildDetails: function getNodeChildDetails(rowItem) {
          if (rowItem.participants) {
            return {
              group: true,
              // open C be default
              expanded: rowItem.group === 'Group C',
              // provide ag-Grid with the children of this group
              children: rowItem.participants,
              // the key is used by the default group cellRenderer
              key: rowItem.group
            };
          } else {
            return null;
          }
        },
        onGridReady: function (params) {
        },
        icons: {
          groupContracted: '<img src="https://raw.githubusercontent.com/ag-grid/ag-grid/master/grid-packages/ag-grid-docs/src/javascript-grid-icons/minus.png" style="height: 12px; width: 12px;padding-right: 2px"/>',
        }
      };
    

    【讨论】:

    • 谢谢 .. 它的工作原理,但在文档中它被给出为“如果在网格选项和列定义中都定义,列定义将被使用”
    • 是的,它的书面,idk更多关于这个,没有用太多
    【解决方案2】:

    尝试下载img文件并将其用作本地资产

    【讨论】:

      猜你喜欢
      • 2021-01-10
      • 1970-01-01
      • 2019-05-23
      • 1970-01-01
      • 2017-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多