1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Filter PrimeNG Table on Init using .ts code

Discussão em 'Angular' iniciado por Domagoj Hamzic, Novembro 28, 2025.

  1. I need to filter the table on view load.

    For example, I have a table with 5 columns (Woid, Customer, AdapterID, Assignee, Status). On load, I want to filter woid column using 'contains'. I accomplished filtering onLoad but when I want to filter again that column later I got an error:


    'Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.'
    ​

    Program code below...

    @ViewChild('dt', { static: true }) dt: any;
    ngOnInit() {
    this.dt.filter('22', 'woid', 'contains');
    }


    [​IMG]

    Also, after filtering via .ts code (woid filter) and directly in view with <p-columnFilter> (customer filter) from PrimeNG Angular collection, I get this JSON. woid property is not an array, unlike custom which is. onFiltering method and JSON below.

    onFiltering(event: any) {
    console.log('Filtered value: '+ JSON.stringify(event.filters));
    }


    {
    "woid": {
    "value": "22",
    "matchMode": "contains"
    },
    "customer": [{
    "value": "2",
    "matchMode": "contains",
    "operator": "and"
    }]
    }

    Continue reading...

Compartilhe esta Página