othanda
othanda

Reputation: 51

Ag-grid Custom Filter: filterParams - cellRenderer in Angular 1.x

According to the documentation, https://www.ag-grid.com/best-angularjs-data-grid/index.php, if I set the angularCompileFilters option to true in a grid's options object, the template in a cellRenderer will be taken as an Angular directive.

However, I can only make the Angular compilation work for the cells - not the heading filters. Is it because it only works with the Ag-Grid-Enterprise version? Or is it simply a bug?

Besides, I do not see any properly-documented sample snippets for that as well.

Upvotes: 4

Views: 5783

Answers (1)

mrtig
mrtig

Reputation: 2267

It works on filters too, you just need to set up a custom filter:

this.gridOptions = { 
    angularCompileFilters:true,
    columnDefs: [{
        headerName: "My Column",
        field: "MyColumn",
        filter: function () {
            this.init = function (params) {
                //init logic
            } 

            this.getGui = function () {
                return "<p ng-repeat=\"i in \'abc\'\">{{i}}</p>"
            }
            this.isFilterActive = function () { 
                return true; 
            }

            this.doesFilterPass = function (params) {
                //filter logic 
                return true;
            }
            this.getModel = function () {
                return { name: "" }
            }

            this.setModel = function (model) {
            }
      }
}

The string returned by getGui will be compiled as an angular component.

Upvotes: 0

Related Questions