set page on p:datatable

后端 未结 4 592
小蘑菇
小蘑菇 2020-12-14 20:59

I\'ve a datatable in primefaces and I want, when I add a row in it, view the last page of the datatable.

My .xhtml page is:


...         


        
4条回答
  •  春和景丽
    2020-12-14 21:18

    I would do it without any JavaScript. Primefaces's datatable has a first attribute, which is the index of the first data to display.

    
    ...
    
    

    And your backing bean:

    public class CalculatePageTable {
        private int first = 1;
    
        public int getFirst(){
            return first;
        }
    
        public void addRow(){
            // 1. your stuff for adding the row 
            ...
            // 2. switch to the row
            first = getFirstRowOnLastPage(); 
        }
    
        private int getFirstRowOnLastPage(){
            ...
        }
    }
    

提交回复
热议问题