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

Link SimpleFormIterator reOrder function to a data field. #6601

Closed
CleverAtBen opened this issue Sep 21, 2021 · 6 comments
Closed

Link SimpleFormIterator reOrder function to a data field. #6601

CleverAtBen opened this issue Sep 21, 2021 · 6 comments

Comments

@CleverAtBen
Copy link

CleverAtBen commented Sep 21, 2021

The new feature for re-ordering the SimpleFormIterator is great UI, however as it has been implemented as default functionality it frustratingly doesnt tie together with my data implementations where I have specified data fields which define the order of items in an Array.

Ideally the feature should enable the user to specify an index field so the order data can be preserved.

Maybe something like this


<SimpleFormIterator orderSource="displayOrder">
... 
</SimpleFormIterator>

@djhi
Copy link
Collaborator

djhi commented Sep 21, 2021

Tagging this as a feature request. However, you can create your own iterator

@etienne-bondot
Copy link

Also we need documentation about disableReordering and reOrderButtons properties 🙏

@WiXSL
Copy link
Contributor

WiXSL commented Jan 31, 2022

Also we need documentation about disableReordering and reOrderButtons properties 🙏

This has been added in #7104

@MoralCode
Copy link

MoralCode commented May 30, 2022

took a quick look at the source behind this and, having no experience with the codebase, I couldn't immediately see an easy way to hook this behavior up. Someone more experienced with the codebase would probably have a better idea of what to look for.

In the meantime, i did notice that the ordering of elements within SimpleFormIterator seems to be initially determined by the order in which they are present in the JSON response from the server, so if you prefer to disable the reordering and enforce a particular order, and if you control the server where the data is coming from, then solutions like that may be a decent workaround.

Alternatively (and this is the workaround i used), it is possible to apply sorting to the data in the dataProvider before it gets to your UI

@CleverAtBen
Copy link
Author

took a quick look at the source behind this and, having no experience with the codebase, I couldn't immediately see an easy way to hook this behavior up. Someone more experienced with the codebase would probably have a better idea of what to look for.

In the meantime, i did notice that the ordering of elements within SimpleFormIterator seems to be initially determined by the order in which they are present in the JSON response from the server, so if you prefer to disable the reordering and enforce a particular order, and if you control the server where the data is coming from, then solutions like that may be a decent workaround.

Alternatively (and this is the workaround i used), it is possible to apply sorting to the data in the dataProvider before it gets to your UI

That would be a solution, but one that would be bespoke to every instance where you wanted to capture the order data explicitly (which you presumably do if you want the use of the reorder UI function). I've got many instances in my solution when capturing order of array items is required.

My fix/fudge for this was to create a bespoke read-only 'indexLinked' input field which sets the form value to the value of the current index in the array.

Happy to share code if it helps anyone else looking for a solution.

@fzaninotto
Copy link
Member

fzaninotto commented Jul 22, 2022

This enhancement request hasn't gained enough interest to get a PR from the community. As we canot keep all feature requests open, I'm closing it.

If you feel like working on this feature, we'd love a PR!

And if you need this feature, you can hire the react-admin core team to develop it for you.

@fzaninotto fzaninotto closed this as not planned Won't fix, can't repro, duplicate, stale Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants