Search code examples
sortingprimefaces-datatable

Sort Primefaces DataTable column with two Columns names in sortBy attribute


I would like to sort a dataTable which has column named "CustomerName" which needs to be sorted based on Customer's FirstName & LastName. So i'd like to pass value to sortBy attribute as shown below sortBy="CustomerTable.FirstName,CustomerTable.LastName"

When i try this i get a parser error stating that String

I am able to sort a column with one table name & column name as input like shown below sortBy="CustomerTable.CustomerNumber"


Solution

  • sortBy="CONCAT(CustomerTable.FirstName,' ',CustomerTable.LastName)" This will sort the column in alphabetical order after concatenating the FirstName and LastName columns of CustomerTable