【问题标题】:Does angular-ui-grid allow for changing the filter on a specific cell?angular-ui-grid 是否允许更改特定单元格上的过滤器?
【发布时间】:2019-03-30 01:25:56
【问题描述】:

我找到了很多关于 angular-ui-grid 单元格过滤器的好信息,但我似乎无法找到我的具体问题的答案。基本上我有一个包含两列的网格:

A 列是一个可编辑的单元格下拉列表,您可以在其中选择两个选项,“金钱”或“百分比”。 B 列是显示值的数字输入。

我的应用中有两个过滤器,“货币”和“百分比”。如果我为这些过滤器中的任何一个设置 columnDefs,则 B 列会将该列中的所有值显示为货币值或百分比。

我需要它做的是使它根据 A 列的设置将过滤器应用于 B 列,所以我最终得到了这个:

Value Type               Value
---------------------------------------
Money                    $100.00
Percentage                100%

我有一些代码可以在编辑后进行检查:

        $scope.gridApi.edit.on.afterCellEdit($scope, function(rowData) {
                var row = _.indexOf($scope.items, rowData);
                if (rowData['valueType'] == 'percentage') {
                    // Apply percentage filter to the value cell for this row
                } else {
                   // Apply currency filter to the value cell for this row
                }
                $scope.gridApi.core.refresh();
        });

...我只是不确定如何将过滤器应用于单个单元格。任何指导将不胜感激!

【问题讨论】:

    标签: angular-ui-grid


    【解决方案1】:

    如果其他人有同样的问题,我通过创建一个将行实体作为参数的过滤器来解决这个问题,然后根据实体值在该新过滤器中应用自定义过滤器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多