0

Is possible to set default sort column on specific datatable in bean? I'm using dynamic datatables and I can't do this in xhtml file. I need to get this column name (ex. tab:tabDataList:j_idt39:1 ) from database and when I open this page, this column should be selected.

enter image description here

I tried to use everything ex.

DataTable dataTable = (DataTable) FacesContext.getCurrentInstance().getViewRoot().findComponent(tableId);

org.primefaces.component.api.UIColumn uiColumn = dataTable.findColumn(this.sortBy);
            dataTable.setSortColumn(uiColumn);
            dataTable.setSortField(this.sortBy);
            dataTable.setSortOrder(this.sortColumnOrder);

            ValueExpression columnSortByVE = uiColumn.getValueExpression("sortBy");
            dataTable.setDefaultSortByVE(columnSortByVE);
Algeroth
  • 785
  • 3
  • 12
  • 29
  • Maybe this article can help you https://stackoverflow.com/questions/42955667/primefaces-datatable-default-sortby-from-backing-bean – peterremec Sep 14 '18 at 06:10
  • Unfortunately no, because in this case, there are using sort listener with SortEvent. In my case, I must to load this settings without any user interraction :( – Algeroth Sep 14 '18 at 06:57

0 Answers0