We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32163
    • 33 Posts
    Hi guys! I created simple component using MIGXdb and I got a question of how to set default sort order (ascending in my case) to its grid. The problem is that I need to see last records from custom table sorted by 'createdon' field in ascending order, but component shows records in descending order only, no matter what field I tried to sort them by.
    In my component configuration I found "MIGXdb-settings" tab with "getlist defautsort" field, but had no luck trying to set sort order while using it. What am I doin' wrong and how to solve this problem? I would appreciate any possible help
      • 4172
      • 5,888 Posts
      There isn't a configuration-option for default-sortorder yet, but you can set the column to sortable.
      Than you can sort by that field from grid-column-headers.

      Or you can create a copy of the components/migx/processors/mgr/default/getlist.php

      in components/yourpackage/processors/mgr/default/getlist.php
      and set the sortOrder to 'DESC' by default in that processor-file.

      MIGXdb will find yor new created processor in your package-directory automatically
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 32163
        • 33 Posts
        Tnanks!
          • 577
          • 132 Posts
          Quote from: Bruno17 at Jul 15, 2012, 12:01 PM
          There isn't a configuration-option for default-sortorder yet, but you can set the column to sortable.
          Than you can sort by that field from grid-column-headers.

          Or you can create a copy of the components/migx/processors/mgr/default/getlist.php

          in components/yourpackage/processors/mgr/default/getlist.php
          and set the sortOrder to 'DESC' by default in that processor-file.

          MIGXdb will find yor new created processor in your package-directory automatically

          Bruno17,

          This post is nearly 4 years old. Is this still the best solution for handling sorting?
            "One of these days I will get around to my own website... Its only been about 12 years... maybe tomorrow smiley"
            • 577
            • 132 Posts
            Quote from: aesmith at May 12, 2016, 06:03 PM
            Quote from: Bruno17 at Jul 15, 2012, 12:01 PM
            There isn't a configuration-option for default-sortorder yet, but you can set the column to sortable.
            Than you can sort by that field from grid-column-headers.

            Or you can create a copy of the components/migx/processors/mgr/default/getlist.php

            in components/yourpackage/processors/mgr/default/getlist.php
            and set the sortOrder to 'DESC' by default in that processor-file.

            MIGXdb will find yor new created processor in your package-directory automatically

            Bruno17,

            This post is nearly 4 years old. Is this still the best solution for handling sorting?

            Nevermind. I knew there had to be a way and I figured it out.

            If anyone else runs into this issue with the latest version MIGX (MIGXdb is build in now) you need to set either of the following under "MIGXdb-Settings"

            "getlist defaultsort" = name of field. (NOTE: you need to add your own `fieldname` if it is a reserved word)
            "getlist defaultdir" = ASC or DESC

            [OR]

            "Sort Config" with an json string that represents and array NOT just a simple object
            ex: [{"sortby":"`order`","sortdir":"ASC"}]

            I had assumed this was how to do it originally before posting but it was failing every time in both setups. The issue was the I was using "order" without the ``. I should use "rank" instead.
              "One of these days I will get around to my own website... Its only been about 12 years... maybe tomorrow smiley"