首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >外部滤镜ag

外部滤镜ag
EN

Stack Overflow用户
提问于 2020-02-29 04:12:04
回答 2查看 146关注 0票数 0

我试图添加一个外部过滤器,但首先,它不起作用,现在我的网格没有显示,它停留在加载中,所以我没有过滤器和网格。

目前我正在对数据进行硬编码,首先,我想确保它正常工作,然后我将从API中获取数据。

代码语言:javascript
复制
export class AgreementListComponent implements OnInit {
    private gridApi;
    private gridColumnApi;
    ageType = "";

    private columnDefs;
    private defaultColDef; 
    private rowData: [
    {
        title: 'Agreement 1', status: 'Status 1', type: 'Type 1', effectiveDate: 'February/28/2020', 
        expirationDate: 'February/28/2020',
        upcomingStipulations: 'Upc Stip 1', overdueStipulations: 'Over Stip 1'
    },
    {
        title: 'Agreement 2', status: 'Status 2', type: 'Type 2', effectiveDate: 'February/28/2020', 
        expirationDate: 'February/28/2020',
        upcomingStipulations: 'Upc Stip 2', overdueStipulations: 'Over Stip 2'
    }
    ];

    constructor() {
        this.columnDefs = [
            { headerName: "Agreement Title", filter: true, field: 'title' },
            { headerName: "Status", filter: 'agTextColumnFilter', field: 'status' },
            { headerName: "Agreement Type", filter: true, field: 'type' },
            { headerName: "Effective Date", filter: true, field: 'effectiveDate' },
            { headerName: "Expiration Date", filter: true, field: 'expirationDate' },
            { headerName: "Upcoming Stipulations", filter: true, field: 'upcomingStipulations' },
            { headerName: "Overdue Stipulations", filter: true, field: 'overdueStipulations' },
    ]

    this.defaultColDef = { filter: true };
    }

    onGridReady(params) {
        this.gridApi = params.api;
        this.gridColumnApi = params.columnApi;
        this.rowData =   this.rowData
    }

    isExternalFilterPresent() {
        return this.ageType != "everyone";
    }

    externalFilterChanged(newValue) {
        console.log('externalFilterChanged')
        this.ageType = newValue;
        this.gridApi.onFilterChanged();
    }

    doesExternalFilterPass(node) {
        switch (this.ageType) {
            case "below30":
            return node.data.status = 'Status 1';
        default:
            return true;
        }
    }
    ngOnInit() {

    }

}

这是我的Html

代码语言:javascript
复制
<div>
    <button (click)="externalFilterChanged('Status 1')">Status 1</button>
</div>
<ag-grid-angular style="width: 100%; height: 400px;" class="ag-theme-balham" 
    [rowData]="rowData"
    [columnDefs]="columnDefs" 
    [doesExternalFilterPass]="doesExternalFilterPass" 
    [isExternalFilterPresent]="isExternalFilterPresent"
    [animateRows]="true"
    [defaultColDef]="defaultColDef"
    [enableSorting]="true"
    [enableFilter]="true"
    (gridReady)="onGridReady($event)">
</ag-grid-angular>

我试着遵循这个guide,但是我不明白为什么过滤器之前不能工作,或者为什么我的网格不再显示。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-06-26 19:00:27

ageType应该是在类外部声明的全局变量。

再看一遍这个例子:

https://www.ag-grid.com/javascript-grid-filter-external/

票数 1
EN

Stack Overflow用户

发布于 2020-09-02 01:02:14

您似乎没有导入ClientSideRowModelModule模块类型

代码语言:javascript
复制
public modules: Module[] = [ClientSideRowModelModule];

查看此plunkr

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60458634

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档