Does the ng grid support cell filter (angular filter) line by line

ng-gird colDefs (column definition) allows you to define a filter (angular filter) for each column.

In my use case, I need to use a filter for each row. This means that the data in some rows will have a number format, while others may have a percentage.

Does the ng-grid filter in line? Note that this is not row filtering, this is the application of the same display format to row cells.

+4
source share
2 answers

This is now (since 2014) possible initially with the current ngGrid:

columnDefs: [
  {
    field: 'name',
    cellFilter: 'lowercase'
  }
]

Or even with filter arguments:

columnDefs: [
  {
    field: 'name',
    cellFilter: 'currency:"GPB"'
  }
]
+11

, cellTemplate .

gridOptions :

    var statusTpl = '<div  style="padding-top: 10px;padding-left: 5px" ng-bind="row.getProperty(col.field) | percentage:200"></div>';
    $scope.gridOptions = {
    data: 'myData',
    columnDefs: [{
      field: 'name'
    }, {
      field: 'status',
      cellTemplate: statusTpl
    }]
    };

( 100% = 200):

    app.filter('percentage', function() {
      return function(input, max) {
        if (isNaN(input)) {
          return input;
        }
        return Math.floor((input * 100) / max) + '%';
      };
    });

100% - CellTemplate.

, , .

Doh! Plunker

+2

Source: https://habr.com/ru/post/1543705/


All Articles