To get the row number of the selected primefaces datatable row

前端 未结 2 1151
广开言路
广开言路 2021-01-02 07:51

I have a primefaces datatable i need to display (selected row number) of (total number of rows) in the JSF page.I could get the row numbers displayed in one of the columns

2条回答
  •  孤城傲影
    2021-01-02 08:53

    I'm surprised by the complex solution in the other answer. Assuming you you have the #{workSpaceBean.lpInfoList} serverside when doing the 'select', you can easily do (code according to the PrimeFaces showcase, adapt according to your needs)

    
    
    public void onRowSelect(SelectEvent event) {
        int rownum = cars.indexOf((Car)event.getObject());
    
    }
    

提交回复
热议问题