We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39519 ☆ A M B ☆
    • 79 Posts
    I just noticed that sort is is being ignored after updating to 2.2.9pl. All of my grid queries are defaulting to "ID" which is not ideal.

    E.g. Extending modObjectGetListProcessor
    class directorydbGetBusCatListProcessor extends modObjectGetListProcessor {
        public $classKey = 'directoryDBcats';
        public $languageTopics = array('directorydb:default');
        public $defaultSortField = 'title';
        public $defaultSortDirection = 'ASC';
    


    The grid looked like it was working until I added an item, which had a title starting with "A". It was placed at the bottom of the list! I'm also using the "group" option, and it is creating a separate group for the new item (which is identical to the group that appears before it.)

    Perhaps this is an extJS update issue?
      Mat Dave Jones
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      Mark Hamstra Reply #2, 13 years ago
      Would be useful to see your ExtJS for the grid and inspecting the AJAX requests to your connector-processor. It might be passing a sort and dir url field already, overwriting the defaults in the processor.
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 39519 ☆ A M B ☆
        • 79 Posts
        I think it was the grouping that was throwing everything off. But mainly I wanted to sort by two items anyway, so the correct method for grouping AND sorting by different fields was to alter the getData() function.

         public function getData() {
                $data = array();
                 $limit = intval($this->getProperty('limit'));
                 $start = intval($this->getProperty('start'));
        
                /* query for chunks */
                 $c = $this->modx->newQuery($this->classKey);
                 $c = $this->prepareQueryBeforeCount($c);
                 $data['total'] = $this->modx->getCount($this->classKey,$c);
                 $c = $this->prepareQueryAfterCount($c);
        
                 $c->sortby('parentid','ASC');
                 $c->sortby('title','ASC');
                 if ($limit > 0) {
                     $c->limit($limit,$start);
                 }
        
                 $data['results'] = $this->modx->getCollection($this->classKey,$c);
                 return $data;
             }
        


        Self Solved (thanks to fossies!)
          Mat Dave Jones