primefaces - Jsf dataTable sortby, I want (1,2,3,4,10,15), I get (1,10,15,2,3,4). How to solve -


my jsf code goes this:

<p:datatable var="result" value="#{timerconfigurationjoblist.model}" rows="10"                          paginator="true" paginatorposition="bottom"                          paginatortemplate="{rowsperpagedropdown} {firstpagelink} {previouspagelink} {currentpagereport} {nextpagelink} {lastpagelink}"                          rowsperpagetemplate="10,20,50" id="approvaltable" lazy="true">                            <p:column sortby="#{result.jobid}">                     <f:facet name="header">                         <h:outputtext value="#{msg['content.joblist.jobid']}"/>                     </f:facet>                 </p:column >  </p:datatable> 

the result :

'wrongly sorted'

as can seen in picture: '123' higher '2', '4', '7' , '9'. want come right @ end, 'numerically' sorted.

am using java , jsf 2.

edit: in lazy model found this:

@override     public final list<t> load(int first, int pagesize, string sortfield, sortorder sortorder,             final map<string, object> filters) {          map<string, sort> sorts = new hashmap<>();          if (sortfield != null) {             if (sortorder.equals(sortorder.ascending)) {                 sorts.put(sortfield, sort.asc);             } else if (sortorder.equals(sortorder.descending)) {                 sorts.put(sortfield, sort.desc);             }             // unsorted can ignored         } 

there multiple ways solve issue:

  1. change type of column mentioned @kukeltje. not sure whether want change schema.
  2. use sortfunction attribute of column provide custom sorting.
  3. pass sorted list of jsf component.

Comments

Popular posts from this blog

'hasOwnProperty' in javascript -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

How to understand 2 main() functions after using uftrace to profile the C++ program? -