3

I have a related field in a custom module that links to a contact. If I activate sorting for this field (listviewdefs.php: sortable=>true) sorting works correctly by using the name field of the contact.

How could I sort by the last_name and then the first_name instead?

Star
  • 3,222
  • 5
  • 32
  • 48
pauel
  • 908
  • 10
  • 26

1 Answers1

2

If first_name and last_name both are db fields then you can apply sorting on listview just like name field (listviewdefs.php: sortable=>true). You only need to add this code

first_name' => array( 'query_type'=>'default'), 'last_name' => array( 'query_type'=>'default'),

in searchFields.php file.

Star
  • 3,222
  • 5
  • 32
  • 48
  • But the db fields for first_name and last_name are in another module. i.e. my module has a link/relate field to contacts and I want to sort in my modules list view using the last_name of the related contact instead of the name field. – pauel Dec 04 '14 at 17:15
  • Hi Pauel, here is a twist if you have related field of Contact in your module then you can achieve this functionality. And If many contacts can associate with your module then you will not be able to achieve this. – Muhammad Saad Shahid Dec 05 '14 at 05:41