Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] - change order of records by drag and drop #362

Open
DriveSoft opened this issue Jun 19, 2024 · 5 comments
Open

[FEATURE] - change order of records by drag and drop #362

DriveSoft opened this issue Jun 19, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@DriveSoft
Copy link

Summary

Pretty often we need to add order for records by adding an "order" column in a table.

Basic Example

So we could specify in options.tsx a column which is going to be responsible for that feature, to keep the order in that column.

Example:

  SocialLinks: {
     title: "Social links",
     dndOrderColumn: "order",
     list: {
        display: ["name", "icon", "active"]
     },
     edit: {
        display: ["name", "icon", "active"]
     }
  }, 

Drawbacks

No response

Unresolved questions

No response

@DriveSoft DriveSoft added the enhancement New feature or request label Jun 19, 2024
@cregourd
Copy link
Collaborator

cregourd commented Jun 19, 2024

Since v.4.0.0 you can do this by adding orderField in field options, this works with relation model and one-to-many relationship as the example below 👇

categories: {
relationOptionFormatter: (category) => {
return `${category.name} Cat.${category.id}`;
},
display: "list",
orderField: "order",
relationshipSearchField: "category",
},

⚠️ Note that this feature is only available in the listview

Let us know if you have any issue with this issue 🚀

@DriveSoft
Copy link
Author

DriveSoft commented Jun 19, 2024

Cool, I did not know that.

But in my case I have a table SocialLinks which does not have any relationships, so I can see records only as a table on main screen and I would like to be able to change order of records on main screen, not on a form.

@cregourd
Copy link
Collaborator

cregourd commented Jul 1, 2024

Currently, Next-Admin doesn't do submit on list view, it's actually a display page.

As we understand, you need a submit button on list view and drag'n'drop system to change the order field automatically.

But this view is incompatible with current view, because drag'n'drop order can't work with list page using filter system, search or even pagination. So' this feature needs a new page, independent of list and form view

We are working on a new major release, where it might be easier to implement this kind of enhancement.

Let us know if you have some details about the implementation you need 🚀

@DriveSoft
Copy link
Author

I got it.
Most of the time you need to change order for data with few records, so what if this feature will work only if there is only one page (with ability to set number of records on a page in model) and when data shows without any filter? :)

image

@cregourd
Copy link
Collaborator

cregourd commented Jul 1, 2024

Maybe it's better to keep the normal list view and add a "sort mode" that will remove the search, filter, sort (header columns) and pagination, adds a drag'n'drop and a button to save that save and exit from the "sort mode".

This way we keep the useful list manipulations in the "classic mode" and allow ordering

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants