1

For those using the (in my opinion excellent) JDeveloper component on Joomla 3.6 to create custom components, I've noticed that there is an issue on the admin table layout whereby you can not sort the columns or use the ordering feature.

  • Could you please post the solution as a proper answer below – Lodder Sep 20 '16 at 13:00
  • Thanks for the tip @Lodder, answer moved from question an put where it belongs in the answer section – philip Sep 21 '16 at 7:52
1

Here are the fixes that you need to do to get them to work

Open

/administrator/com_yourcomponent/views/yourviewplural/tmpl/default.php

You'll see a line

$saveOrder = ($listOrder == 'ordering' && isset($this->items[0]->ordering));

Notice it checks the listOrder to be equal to 'ordering' (we'll get back to this)

Just below, change

$saveOrderingUrl = 'index.php?option=com_yourcomponent&task=yourviewplural.ordering&tmpl=component';

To

$saveOrderingUrl = 'index.php?option=com_yourcomponent&task=yourviewplural.saveOrderAjax&tmpl=component';

Scroll down utill you get to the table headings.

The first column is the ordering column, here is where the next bug sits. Notice that is has the ordering target set to 'a.ordering' but our variable $saveOrder checks for 'ordering'

change

<?php echo JHtml::_('searchtools.sort', '', 'a.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?>

To

<?php echo JHtml::_('searchtools.sort', '', 'ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?>

I've found that searchtools.sort and grid.sort do not seem to work together so replace all occurances of grid.sort with searchtools.sort

If you have a 'featured' column you will need to make another modification as you can't use the title to display the featured icon. searchtools does however have a parameter for icon.

change

<?php echo JHtml::_('grid.sort', JText::_('<span class="icon-featured"></span>'), 'a.featured', $listDirn, $listOrder) ?>

To

<?php echo JHtml::_('searchtools.sort', null, 'a.featured', $listDirn, $listOrder, null, null, 'Featured', 'icon-featured') ?>

Save the file, we're done with this one.

Open /administrator/com_yourcomponent/models/forms/filter_yourviewplural.xml

Scroll to the bottom where you will see the list field with the name="fullordering" In the option list find a.ordering ASC and a.ordering DESC and remove the a.

i.e from

<option value="a.ordering ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering DESC">JGRID_HEADING_ORDERING_DESC</option>

To

<option value="ordering ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="ordering DESC">JGRID_HEADING_ORDERING_DESC</option>

Save the file. We are done, sort and ordering now work as they should. Hope this helps someone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.