Sorting is not working in datatable in PrimeFaces?

后端 未结 7 2451
感情败类
感情败类 2020-12-15 07:13

Sorting is not working in datatable in PrimeFaces. Please suggest.

See below my .xhtml file



  

        
7条回答
  •  不思量自难忘°
    2020-12-15 07:37

    The primefaces backing bean (ViewScoped!) must hold it's own List of rows. So, e.g., if you query the database every time you request the p:dataTable:value, sorting will not work.

    Solution: Collect the List from the Database and keep it in a local List variable in the backing bean.

    public List getDataTable() {
        if (tableDataList == null)
            tableDataList = loadListOnce();
        return tableDataList;
    }
    

提交回复
热议问题