Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Default sort order in list view

  1. #1
    door3ahmed is offline Senior Member
    Join Date
    Nov 2008
    Posts
    33

    Default Default sort order in list view

    I'm trying to have a list view default its sort order to one of the fields, is there a way to do this?

  2. #2
    sugarcane is offline Sugar Community Member
    Join Date
    Apr 2005
    Location
    Chicago, IL
    Posts
    1,207

    Default Re: Default sort order in list view

    Hello,

    what module and what field are you trying to sort on? You should be able to click on the field name in the list view, and the list should sort in that order (you can sort ascending or descending). This is on a user by user basis, so the sorting should stick if you change it.

    If the field you want to sort by is not sortable, you can modify this in the listviewdefs.php file:

    custom/modules/<ModuleName>/metadata/listviewdefs.php
    and set
    'sortable' => true,
    Intelestream has a great deal of experience hosting and customizing the SugarCRM application. Our company is made up by former employees of SugarCRM, and together we have over 50 years of experience working with the application. To learn more about us, please visit our website at www.intelestream.net or contact us directly at 800-391-4055 or by email at info@intelestream.net

  3. #3
    door3ahmed is offline Senior Member
    Join Date
    Nov 2008
    Posts
    33

    Default Re: Default sort order in list view

    Opportunities module, and a custom field.

    It's sortable but I want it to be sorted by the custom field by default, so when a new user comes in it's already sorted properly.

  4. #4
    hugoyar is offline Member
    Join Date
    Feb 2009
    Posts
    10

    Default Re: Default sort order in list view

    Have a look to:
    http://www.sugarcrm.com/forums/showt...ght=sort+order

    I'm actually trying to do the same think. Not yet succesfull, but I'm getting close I think.

  5. #5
    SugarDev.net is offline Sugar Community Member
    Join Date
    Feb 2008
    Posts
    1,401

    Default Re: Default sort order in list view

    this is not possible afaik. I agree it's not an advantage that an admin is not able to control more of the user settings.
    Developers go here
    Businesses go there (Dutch)

    Modules:
    SugarDev.net Developer Tools | Config | Dutch Language Pack
    "Nothing gets fixed unless there is a bug"

  6. #6
    hugoyar is offline Member
    Join Date
    Feb 2009
    Posts
    10

    Default Re: Default sort order in list view

    After several tests I finally isolate one file that can be changed :

    \custom\modules\MyModul\Ext\Layoutdefs\layoutdefs. ext.php


    $layout_defs["MyModule"]["subpanel_setup"]["MyModuleSubPanel"] = array (
    'order' => 100,
    'module' => 'MyModule',
    'subpanel_name' => 'default',
    'sort_order' => 'desc',
    'sort_by' => 'name',
    );

    Not yet understand how all this work because SubPanel.php seems to require those in something like $layout_defs[$module]['custom_subpanel_defines'][$subpanel_id]. It is also make reference to an _override prefixed file. This seems to be explained in :
    http://developers.sugarcrm.com/docs/...4.html#9002252
    but I do not yet have tested this"repair" action.
    Still working on it...

  7. #7
    hugoyar is offline Member
    Join Date
    Feb 2009
    Posts
    10

    Default Re: Default sort order in list view

    ok, it works. So I should just RTFM.

    If you want to also remove 'select' or 'create' button in subpanel, just add an empty array as 'top_buttons':

    $layout_defs["MySourceModule"]["subpanel_setup"]["MySource_MyDest"] = array (
    'order' => 100,
    'module' => 'myDstModule',
    'subpanel_name' => 'default',
    'sort_order' => 'desc',
    'sort_by' => 'name',
    'title_key' => 'LBL_MySource_MyDest_FROM_MyDest_TITLE',
    'get_subpanel_data' => 'MySource_MyDest',
    'top_buttons' =>
    array (
    ),
    );

  8. #8
    martyM is offline Junior Member
    Join Date
    May 2009
    Posts
    3

    Default Re: Default sort order in list view

    NONE of these are the answer for the question, I think... I'm trying to solve this too and I get to this point:

    if I add to "include/ListView/ListViewData.php" around line 280 just before the line :

    PHP Code:
    $ret_array $seed->create_new_list_query($orderBy$where$filter_fields$params0''true$seedtrue); 
    this:

    PHP Code:
    // set default sort order for MyModule
    if ($GLOBALS['module'] == 'MyModule')
    {
        
    $orderBy 'MyModule.MyField DESC';

    I've got list (classic list view NOT subpanel list) ordered by MyField by default...

    BUT:
    with this I lost opportunity to order list by another field...
    Last edited by martyM; 2009-05-12 at 08:53 AM.

  9. #9
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: Default sort order in list view

    Hi Marty

    This is not an upgrade safe approach.
    You may consider creating a view.list.php for your module, implement the method listViewPrepare with this content:

    PHP Code:
    function listViewPrepare() {
      if(empty(
    $_REQUEST['orderBy'])) {
        
    $_REQUEST['orderBy'] = 'MyModule.MyField DESC';
      }

      
    parent::listViewPrepare();

    Cheers
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  10. #10
    martyM is offline Junior Member
    Join Date
    May 2009
    Posts
    3

    Default Re: Default sort order in list view

    Hi Andopes,

    i know, it's not upgrade safe, it's just one solution (I'm not saying it's the best ) I found.

    Anyway, thank you very much for advice... I'm going to try it that way... Thanks once again!

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Sort columns in list view
    By DN667 in forum Help
    Replies: 12
    Last Post: 2011-05-27, 05:41 PM
  2. SubPanel default sort order
    By Bryan in forum Developer Help
    Replies: 5
    Last Post: 2010-11-29, 12:44 PM
  3. Edit Default ListView Sort Order?
    By tj@estreet.com in forum Feature Requests
    Replies: 5
    Last Post: 2009-05-27, 11:50 AM
  4. Replies: 0
    Last Post: 2008-07-04, 12:34 PM
  5. Sugar Web List Sort Order
    By jasonadmin in forum Developer Help
    Replies: 0
    Last Post: 2006-06-25, 11:23 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •