How to use the igniteui-angular.FilteringExpressionsTree function in igniteui-angular

To help you get started, we’ve selected a few igniteui-angular examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github IgniteUI / igniteui-angular-samples / src / app / grid / grid-save-state / state.directive.ts View on Github external
public restoreGridState() {
        // this.loadGridState();

        // restore filtering
        if (this.filtering && this.gridState.filtering) {
            const gridFilteringExpressionsTree = new FilteringExpressionsTree(this.gridState.filtering.operator);

            for (const f of this.gridState.filtering.filteringOperands) {
              const filtOperand = f as FilteringExpressionsTree;
              let columnsFiltOperands: any;

              // We need to make sure that we have a IFilteringExpression[] to pass to the createExpressionsTree method
              // Depending on filtering logic (AND or OR), filtOperand.filteringOperands returns different content,
              // so we have three cases, where to build IFilteringExpression[], see #1, #2 and #3
              if (filtOperand.filteringOperands.length > 1) {
                // #1 filtOperand.filteringOperands is an array of IFilteringExpression objects
                columnsFiltOperands = filtOperand.filteringOperands as IFilteringExpression[];
              } else {
                columnsFiltOperands = filtOperand.filteringOperands[0] as IFilteringExpression;
                if (Array.isArray(columnsFiltOperands.filteringOperands)) {
                  // #2 filtOperand.filteringOperands is an array of just one IFilteringExpression\
                  // containing filteringOperands property, which value is an array of IFilteringExpression objects
github IgniteUI / igniteui-angular-samples / src / app / grid / grid-save-state / state.directive.ts View on Github external
@Directive({
    selector: "[igxState]"
})
export class IgxGridStateDirective implements AfterViewInit {

    public perPage = 15;
    public selection = true;
    public filtering = true;
    public paging = true;
    public sorting = true;
    public columns = true;
    public shouldSaveState = true;

    public initialState: IGridState = {
        filtering: new FilteringExpressionsTree(0),
        paging: {index: 0, recordsPerPage: this.perPage},
        selection: [],
        sorting: [],
        columns: []
    };

    public gridState: IGridState;

    constructor(@Host() @Self() @Optional() public grid: IgxGridComponent, private router: Router) {
    }

    public ngOnInit() {
        this.loadGridState();

        this.router.events.pipe(
            take(1)
github IgniteUI / igniteui-angular-samples / src / app / grid / grid-save-state / state.directive.ts View on Github external
private createExpressionsTree(columnsFiltOperands: IFilteringExpression[],
                                  filtOperand: FilteringExpressionsTree): FilteringExpressionsTree {
        const columnFilteringExpressionsTree =
            new FilteringExpressionsTree(filtOperand.operator, filtOperand.fieldName);
        const column = this.grid.columns.filter((col) => col.field === filtOperand.fieldName)[0];
        for (const fo of columnsFiltOperands) {
            const columnFiltOperand = fo as IFilteringExpression;
            columnFiltOperand.condition = column.filters.condition(columnFiltOperand.condition.name);
            if (column.dataType === "date") {
                columnFiltOperand.searchVal = new Date(Date.parse(columnFiltOperand.searchVal));
            }
            columnFilteringExpressionsTree.filteringOperands.push(columnFiltOperand);
        }
        return columnFilteringExpressionsTree;
    }