MultiValue reset
MultiValue reset
RagnarGrootKoerkamp
Posts: 48Questions: 14Answers: 1
in Editor
It would be nice to have a public function to reset multiValue fields to their initial state, or more generally a function to reset any field to its initial state.
Context:
We have a from with checkbox fields A
, B
, ..., and dependent fields A1
, A2
, B1
, `B2,...
The child fields are only shown when the parent checkbox is on.
We would like to do the following when multiple rows are edited: (the problem is in the third item)
- If all rows have
A
checked, showA1
,A2
as normal fields, with the usual multiValue behavior. WhenA
is unchecked, the child fields are hidden. (Their value is cleared at the server, so this is fine.) - If none of the rows have
A
checked, the child fields will be shown whenA
is clicked. All child fields start empty, so the normal behavior works well. - If
A
is a multiValue, the child fields are hidden initially. WhenA
is checked, the children are shown. Their default multiValue behavior is used. (so far so good) Now, whenA
is reverted by clickingundo changes
, I would like to revert the child fields to their initial state as well, but I don't see how to do this in a nice way. Some of the child fields could be in a multiValue state, so calling the privatemultiReturn.on('click')
function would work, but some might be non-multiValue fields, and I don't know of a way to change those back to their initial state.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
That's interesting - thank you. I hadn't included this ability because I figured that if you were using the API you wouldn't be using the UI for the multi-row editing at the same time. Obviously that isn't the case with your use case.
I can't promise anything as there is a significant feature back log at the moment, but I will look into implementing this. Thanks for the suggestion.
Regards,
Allan
Just a quick thought - perhaps another option would be to read the existing values from the table and use the API to set those values when the event occurs.
Allan
Resetting values by reading them from the table should work well indeed. Thanks!
This will still require a custom event when
Undo Changes
is clicked, but that should be easy to implement myself.Just a quick update here in case anyone else finds this - I've added
field().multiRestore()
to the Editor API which will be available in 1.7.Regards,
Allan