order column drag & drop like joomla

Hello,

I would like to achieve the following:

I have a list ordered and grouped by datetime. I would like to find a way to have a "order" column within each group. Is there a link to an existing topic for this or maybe an easy solution like joomla order column?

- 20.01.2017
-- Task 1
-- Task 2
-- Task 3 (move this to position 2)
- 21.01.2017
-- Task 1 (move this to position 3)
-- Task 2
-- Task3

Thank you
 
Where can I find this plugin? I looked at list and form settings, but there is no "order plugin". Do I have to install such a plugin?
 
Works nice!

Just 2 quick questions.

By deafult when I create a new data row, the "order" column has NULL value. When I drag & drop a row, there will be an integer in "order" column for this specific row. Shouldn't "order" column autoincrement right away, when I add a new row? Otherwise list will show NULL rows first and then those rows with value in "order" column.

See attached screenshot. Is there an option to show Joomla like icons for drag & drop?
 

Attachments

  • 02-02-_2017_18-35-35.jpg
    02-02-_2017_18-35-35.jpg
    37 KB · Views: 104
By default when I create a new data row, the "order" column has NULL value. When I drag & drop a row, there will be an integer in "order" column for this specific row. Shouldn't "order" column autoincrement right away, when I add a new row? Otherwise list will show NULL rows first and then those rows with value in "order" column.

Yes, that would be nice. At the moment, it's left up to you what you want to do with ordering when creating a new row. You could achieve the autoinc by applying an eval'ed default of something like ...

Code:
$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);
// selet max+1, coalesce in case no rows in table
$myQuery->select('COALESCE(MAX(order_element_name), 0) + 1 AS newmax')->from('yourtable');
$myDb->setQuery($myQuery);
return $myDb->loadResult();

In order to achieve that as a built in thing, we'd probably have to create a new element plugin, 'order', which had options for stuff like "order at start or end", and did the ordering on submit, rather than when loading the form. And allowed for doing things like re-ordering the rest of the table ... so if you selected "order at start", it would reorder the entire table with the new row as 1, after this row is saved. But that's a lot of work, and it's not something we've had a lot of requests for. So for the moment, you have to roll your own code to achieve it.

-- hugh
 
Code:
// get a db connection
$db = JFactory::getDbo();
// create a new query object
$query = $db->getQuery(true);
// query
$query
->select('MAX('.$db->quoteName('ok_id').')')
->from($db->quoteName('sc_exercise_category'));

$db->setQuery($query);
$result = $db->loadResult();
$result = $result + 1;

echo $result;

return $result;

Hello,

I am using Cheesegrits code to set a default with the 'ok_id' (order key id) field, which is for sorting. When I add a new data row, the field is populated with the correct value in form, as long as there are no NULL values for 'ok_id' in db. When I add this data row, fabrik will insert NULL for this field in db. Can't really tell at the moment why this is.
 
Last edited:
I have also tested drag & drop on a Samsung Galaxy S6. Didn't work too well, because template also scrolls and drag & drop didn't really work. Not sure if this is related to my template I am using.
 
Last edited:
Never mind. This was my fault.

I am using PHP code with my form, to insert 2 data rows for 2 languages. With this insert, I didn't consider the new 'ok_id' field.

This one is solved!

Still testing the mobile drag & drop. The mobile drag & drop is still having issues on my side. When I try to drag & drop with image, on my mobile I can only download the image and not drag & drop. When I use the value instead of an icon per row, I can't really drag & drop (template will scroll as well and drag & drop stops working once I drag a row).
 
Last edited:
Also, is it possible to use font awesome hmtl to create icons, instead of using an image with each row? I can use html for my heading, but can't replace the ok_id value with a font awesome icon that will scale.
 

Attachments

  • 03-02-_2017_11-40-03.jpg
    03-02-_2017_11-40-03.jpg
    57.2 KB · Views: 98
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top