filterFunction/sortFunction creation

UI Components for React
Post Reply
Agustin Caamaño
Posts: 7
Joined: 14 Dec 2021, 17:54

10 Jan 2022, 16:50

I can't create a filterfunction and sortfunction and i don´t know why.
I want to call the function and then get the data from a database and reload the information of the table
Here is the code i have:

Code: Select all

customFilterData(e) {
        console.log(e)
        var filtros = this.state.filter_data
        if (filtros === undefined){
            filtros = e
        }else {
            if(filtros[filtros.length-1] !== e)
                filtros.push(e)
        }
        this.setState({filter_data : filtros} , ()=>{this.getDataTable()})
    }
    
customSortData(e) {
        console.log(e)
        var sorts = this.state.filter_data
        if (sorts === undefined){
            sorts = e
        }else {
            if(sorts[sorts.length-1] !== e)
                sorts.push(e)
        }
        this.setState({sort_data : sorts}, () => {this.getDataTable()})
    }

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

10 Jan 2022, 19:54

You want to use the lazy example here: https://primefaces.org/primereact/datatable/lazy/

That hooks in to exactly what you want to do to use Sort and Filter as DB queries.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 8 guests