4

I'm developing a custom Joomla component for an application and would like to implement drag-and-drop ordering in a list view on the admin site.

I found an excellent guide here: Adding drag-n-drop ordering in component.

However, something is missing that is not allowing me to save the re-ordering of items. I found that my controller does implement the saveOrderAjax() function because it extends JControllerAdmin, but my model does not implement the saveorder() function because, as it's a list view, I'm extending JModelList, which does not implement saveorder(). Only JModelAdmin has the saveorder() function.

The error I get in the error log is:

PHP Fatal error: Call to undefined method MyComponentModelMyListModel::saveorder() in C:\xampp\htdocs\mysite\libraries\legacy\controller\admin.php on line n

This makes no sense to me because a list view is supposed to use JModelList for its corresponding model, right?
Has anyone succeeded at this task without writing something entirely new?
I don't think extending JModelAdmin for my model here is practical.

1 Answer 1

1

Sounds like you have some of your method logic in the wrong place. Try adding your saveOrder method to your views controller, not to the model. Controllers perform actions, models return data. You will probably want to fire off an ajax call to the controller to perform live sorting.

You can download my JoomRoster component from the JED. Unzip it and look in the admin folder for one of the list views and see how I implemented it.

https://extensions.joomla.org/extensions/extension/contacts-and-feedback/contact-details/joomroster/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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