[ 3 posts ]

CMona

  • Username: cmona
  • Joined: Thu Oct 13, 2011 1:25 am
  • Posts: 12
  • Offline
  • Profile

Changing a sort function for a field in a datatable

Post Posted: Mon Apr 23, 2012 1:57 am
+0-
I have a datatable with column that im sorting first alphabeticaly then when user clicks on a button i want it to be sort numericaly how can i do this , i can't set parser: number because my datatable with it's datasource is already created and rendered .

any ideas ?

Thanks.

Satyam

YUI Contributor

  • Username: Satyam
  • Joined: Tue Dec 09, 2008 12:34 am
  • Posts: 2016
  • Location: Sitges, Spain
  • GitHub: Satyam
  • Gists: Satyam
  • IRC: DevaSatyam
  • YUI Developer
  • Offline
  • Profile

Re: Changing a sort function for a field in a datatable

Post Posted: Mon Apr 23, 2012 7:24 am
+0-
You will have to define your own sort function as shown here:

http://developer.yahoo.com/yui/datatable/#advancedsort

Your sort function should check what type of sort is required and proceed accordingly. You would have to force (type cast) your values into the desired data type to make it work.

CMona

  • Username: cmona
  • Joined: Thu Oct 13, 2011 1:25 am
  • Posts: 12
  • Offline
  • Profile

Re: Changing a sort function for a field in a datatable

Post Posted: Fri Apr 27, 2012 5:12 am
+0-
Thanks for the response satyam ,

I can't use the column definition as in that example because i already have my datatable created ,
i was hoping that there's a way to change a sortfunction after the datatable has been displayed ,
like setting the datatable's attribute sortFunction and maybe refresh the datatable or requery it afterwards.
is this possible ?

Thanks.
  [ 3 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum