2

Here i'm trying change the ordering for the particular group by click and trag in List view.I have several categories and some datas for those categoies.

If I add the below code in my default.php

$saveOrderlistUrl= 'index.php?option=com_xxxx&task=groups.saveOrderAjax&tmpl=component';
JHtml::_('sortablelist.sortable', 'groupsList', 'adminForm', strtolower($listDirn), $saveOrderlistUrl);

Inside Looping data:

<tr class="row<?php echo $i % 2; ?>" sortable-group-id="<?php echo $row->category_id; ?>">

The particular category data only visible when try to click & drag.Thats works fine. After changing the ordering,if I check the database, the ordering for the data is incorrect and its interchanged with overall max(ordering).Not for the particular category datas. Kindly help me to solve this.

1

If I understood you correctly you should add getReorderConditions() method to your Group model:

/**
 * A protected method to get a set of ordering conditions.
 *
 * @param   object  $table A record object.
 *
 * @return  array   An array of conditions to add to add to ordering queries.
 */
protected function getReorderConditions($table)
{
    $condition = array();
    $condition[] = 'catid = ' . (int) $table->catid;

    return $condition;
}

catid is the category field in your table.

getReorderConditions() method is used in reorder() method of JModelAdmin class to apply additional conditions to reorder query.

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.