Sorting table view

Discussions regarding developing applications using Servoy Mobile (new in Servoy 7)

Sorting table view

Postby jdbruijn » Fri Oct 04, 2013 4:58 pm

I want to sort my table view by 2 columns: first by foundset.task_to_call.main_group and then by foundset.task_to_call.sub_group.
How can I do this in the sortfunction?
Jos de Bruijn
Welcome CCS
Servoy Certified Developer
Image
jdbruijn
 
Posts: 445
Joined: Sun Apr 11, 2010 6:34 pm

Re: Sorting table view

Postby david » Fri Oct 04, 2013 8:37 pm

sort("task_to_call.main_group asc, task_to_call.sub_group asc")

Unless I'm not understanding your question....
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1723
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: Sorting table view

Postby david » Fri Oct 04, 2013 8:39 pm

Code example for a form's onSort event/command:

Code: Select all
/**
* Perform sort.
*
* @param {String} dataProviderID element data provider
* @param {Boolean} asc sort ascending [true] or descending [false]
* @param {JSEvent} event the event that triggered the action
*
* @properties={typeid:24,uuid:"CEC04198-198A-4D7A-8383-505C8D08141E"}
*/
function SORT(dataProviderID, asc, event) {
   if (dataProviderID == 'task_to_call.main_group' || dataProviderID ==
'task_to_call.sub_group') {
      controller.sort('task_to_call.main_group' + (asc ? ' asc' : ' desc') + '
task_to_call.sub_group' + (asc ? ' asc' : ' desc'), false)
   }
   else {
      controller.sort(dataProviderID + (asc ? ' asc' : ' desc'), false)
   }
}
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1723
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: Sorting table view

Postby jdbruijn » Mon Oct 07, 2013 9:35 am

my question is about sorting on the mobile client. There you can only sort using:
Code: Select all
foundset.sort(sortFunction)

I was wondering if I can sort using multiple columns using this method.
Jos de Bruijn
Welcome CCS
Servoy Certified Developer
Image
jdbruijn
 
Posts: 445
Joined: Sun Apr 11, 2010 6:34 pm

Re: Sorting table view

Postby david » Mon Oct 07, 2013 11:43 pm

Stumbled into the mobile forums by accident :)
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1723
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: Sorting table view

Postby jcompagner » Wed Nov 27, 2013 5:28 pm

in the function that you give you can do anything you want, you only need to return a -1 (smaller ), 0 (equals) , 1 (greater )
of the 2 records that you get in that sort function, see the doc of the sort by function
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 7974
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet


Return to Servoy Mobile

Who is online

Users browsing this forum: No registered users and 1 guest

cron