如何在 Ag-Grid 过滤器中使用 AngularJS 1?
How to use AngularJS 1 in Ag-Grid filters?
我想在 AngularJS 中为 Ag-Grid 5.2.0 创建一个过滤器。这是我的代码:
var columnDefs = [
{headerName: "Test1", field: "test1", filter: MyCustomFilter},
{headerName: "Test2", field: "test2"},
];
vm.gridOptions = {
enableServerSideSorting: true,
enableServerSideFilter: true,
columnDefs: columnDefs,
datasource: getDataSource(),
paginationPageSize: 10,
rowModelType: 'pagination'
};
// Class function.
function MyCustomFilter() {}
// mandatory methods
MyCustomFilter.prototype.init = function (params) {};
MyCustomFilter.prototype.getGui = function () {return "<div>{{ 'testkey' | translate}}</div>"};
MyCustomFilter.prototype.isFilterActive = function() {return true;};
MyCustomFilter.prototype.doesFilterPass = function (params) { return true;};
MyCustomFilter.prototype.getApi = function () {};
问题是 AngularJS 不评估翻译过滤器。如何将 AngularJS 元素添加到 Ag-Grid 过滤器?
我想出了解决办法:
function getGui() {
var filterScope = $rootScope.$new(true);
var filter = $compile("<div>{{ 'testkey' | translate}}</div>")(filterScope);
filterScope.$digest();
return filter[0];
};
我想在 AngularJS 中为 Ag-Grid 5.2.0 创建一个过滤器。这是我的代码:
var columnDefs = [
{headerName: "Test1", field: "test1", filter: MyCustomFilter},
{headerName: "Test2", field: "test2"},
];
vm.gridOptions = {
enableServerSideSorting: true,
enableServerSideFilter: true,
columnDefs: columnDefs,
datasource: getDataSource(),
paginationPageSize: 10,
rowModelType: 'pagination'
};
// Class function.
function MyCustomFilter() {}
// mandatory methods
MyCustomFilter.prototype.init = function (params) {};
MyCustomFilter.prototype.getGui = function () {return "<div>{{ 'testkey' | translate}}</div>"};
MyCustomFilter.prototype.isFilterActive = function() {return true;};
MyCustomFilter.prototype.doesFilterPass = function (params) { return true;};
MyCustomFilter.prototype.getApi = function () {};
问题是 AngularJS 不评估翻译过滤器。如何将 AngularJS 元素添加到 Ag-Grid 过滤器?
我想出了解决办法:
function getGui() {
var filterScope = $rootScope.$new(true);
var filter = $compile("<div>{{ 'testkey' | translate}}</div>")(filterScope);
filterScope.$digest();
return filter[0];
};