Hi there :-)
I got a little problem. I'm working with the eBook "Learning Joomla! 3 Extensions Development" - at this moment I'm trying to get the table-reordering with drag & drop working.
Well, my admin-field shows the "drag & drog"-column, but I can not drag or drop something (see screenshot).
tmpl/default.php:
<?php
// Den direkten Aufruf verbieten
defined('_JEXEC') or die;
// Das Tooltip Behavior wird geladen
JHtml::_('behavior.tooltip');
JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields');
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
?>
<script type="text/javascript">
Joomla!.orderTable = function()
{
table = document.getElementById("sortTable");
direction = document.getElementById("directionTable");
order = table.options[table.selectedIndex].value;
if (order != '<?php echo $listOrder; ?>')
{
dirn = 'asc';
}
else {
dirn = direction.options[direction.selectedIndex].value;
}
Joomla!.tableOrdering(order, dirn, '');
}
</script>
<form method="post" name="adminForm" id="adminForm">
<?php
if (!empty( $this->sidebar)) :
?>
<div id="j-sidebar-container" class="span2">
<?php
echo $this->sidebar;
?>
</div>
<div id="j-main-container" class="span10">
<?php else : ?>
<div id="j-main-container">
<?php endif;?>
<table class="table table-bordered table-striped table-hover">
<thead><?php echo $this->loadTemplate('head');?></thead>
<tfoot><?php echo $this->loadTemplate('foot');?></tfoot>
<tbody><?php echo $this->loadTemplate('body');?></tbody>
</table>
<div>
<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
<input type="hidden" name="task" value=""/>
<input type="hidden" name="boxchecked" value="0"/>
<?php echo JHtml::_('form.token'); ?>
</div>
</form>
My /tmpl/default_body.php
<?php
// Den direkten Aufruf verbieten
defined('_JEXEC') or die;
$user = JFactory::getUser();
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$canOrder = $user->authorise('core.edit.state', 'com_bestia'); $saveOrder = $listOrder == 'a.ordering';
if ($saveOrder)
{
$saveOrderingUrl = 'index.php?option=com_bestia&task=items.saveOrderAjax&tmpl=component';
JHtml::_('sortablelist.sortable', 'itemList', 'adminForm', strtolower($listDirn), $saveOrderingUrl);
}
$sortFields = $this->getSortFields();
?>
<?php foreach ($this->items as $i => $item): ?>
<?php
$canCheckin = $user->authorise('core.manage','com_checkin') || $item->checked_out == $user->get('id') || $item->checked_out == 0;
$canChange = $user->authorise('core.edit.state', 'com_bestia') && $canCheckin;
?>
<tr class="row<?php echo $i % 2; ?>" sortable-group-id="1">
<td class="order nowrap center hidden-phone">
<?php
if ($canChange) :
$disableClassName = '';
$disabledLabel = '';
if (!$saveOrder) :
$disabledLabel = JText::_('JORDERINGDISABLED');
$disableClassName = 'inactive tip-top';
endif;
?>
<span class="sortable-handler hasTooltip <?php echo $disableClassName?>" title="<?php echo $disabledLabel?>">
<i class="icon-menu"></i>
</span>
<input type="text" style="display:none" name="order[]"size="5" value="<?php echo $item->ordering;?>" class="width-20 text-area-order " />
<?php else : ?>
<span class="sortable-handler inactive" >
<i class="icon-menu"></i>
</span>
<?php endif; ?>
</td>
<td>
<?php echo JHtml::_('
grid.id', $i, $item->id); ?>
</td>
<td class="center">
<?php echo JHtml::_('jgrid.published', $item->state, $i, 'items.', $canChange, 'cb', $item->publish_up, $item->publish_down); ?>
</td>
<td>
<?php echo $item->title; ?>
</td>
<td>
<?php echo $item->category; ?>
</td>
<td>
<?php echo $item->id; ?>
</td>
</tr>
<?php endforeach;
Well, to be precise: I can not "grab" the row :-(