• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question on how to sort tomahawk datatable

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

I'm new to this forum and am stuck in getting tomahawk datatable to sort columns for me.

From searching the web I understood that sortAscending and sortColumn properties should point to properties in the backing bean. For some reason that does not work!!

HELP me I've looked everywhere

My datatable code is :





and my backing bean code is:





Is there something that needs to be written in the methods? help me out here guys
 
Abdul Shams
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Help! Anyone!!
 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Abdul,

I've done this in the past, but not with tomahawk dataTable. So perhaps this might not help, but then again, maybe it does.

I used myFaces dataTable. And I just sorted the List on the backing bean. So in the header of the column I have 2 commands (little up and down arrows) that call a sortXXXAscending or sortXXXDescending method on the backing bean. Then this method just uses the Collections.sort method to sort the actual List containing the data.

This worked fine for me, hope it helps for you.

cheers
Darryl
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You dont really need to link those properties with your backing bean. Try something like this (replacing capital text with your values):

The real trick is the tag t:commandSortHeader
 
Abdul Shams
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Darryl but I thought I'd use it as a last resort. I'm hoping to get the tomahawk way correct which would save a lot of effort i think.

Juan, Thank you as well for your reply but I can't get it to work! Does it have something to do with that I'm using an ArrayList as my datasource?

Here is my ammended datatable




Funny thing is that the arrows don't seem to appear as well!



Guys any help would be really appreciated..






.
[ October 19, 2008: Message edited by: Abdul Shams ]
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
WITHIN your backing bean you must have this:

"sortAscending" must be of type boolean with methods:

public boolean isSortAscending() {
return sortAscending;
}

public void setSortAscending(boolean sortAscending) {
this.sortAscending = sortAscending;
}

"sortColumn" must be of type String with methods:
public String getSortColumn() {
return sortColumn;
}

public void setSortColumn(String sortColumn) {
this.sortColumn = sortColumn;
}

With both of those ALONE you will get the default sort which works when you click on the header title. You can test this by places breakpoints on the setter and you will see values getting set.

To do customized sorting you have to do it on the t:column level (I think). Take a look at what t:column has to offer as attributes.

As for me I'm learning this for the very first time right now but so far what I have told you works for me.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic