Nested editing default value
Nested editing default value
marianidiego
Posts: 56Questions: 18Answers: 1
Link to test case:
https://editor.datatables.net/examples/datatables/nested.html
Description of problem:
What happens when nothing is selected? Or better, if the user deselect all?
Being able to define a default value for this case would be very practical.
Replies
If nothing is selected you can only have an editor "create" event. Is this what you want to refer to?
Setting a default value for this is fairly easy. Just use "initCreate" or "open" with action "create".
Something like this:
You can also address the embedded data table and attach event handlers. This would be the embedded data table which behaves like any other data table
It's all in the docs ... please read. I haven't written data tables either: All I can do is check the docs ...
Just to add to rf1234's post:
An empty value is submitted for the
datatable
field. It has no value, so an empty value is sent. The server-side can be configured to reject that if a value should be submitted.Use
field.def
to define what should be selected as the default value at initialisation time, or use thefield().def()
value after initialisation.Another option would be to have the server, instead of doing validation and rejecting the empty value, have it write a default value instead of empty if an empty value is submitted. I think that might be confusing to the user, but it is an option.
Allan
Thanks, Allan. I must admit that I had forgotten about all the other options. This forum is really helpful when it comes to discovering all of Editor's and Data Tables' rich capabilities! Thanks for providing such a brilliant solution, Allan. Without your solution my little cloud company wouldn't exist: No way for me to code all of the the stuff I need just by myself!
Roland
That's really kind of you to say - thank you. I'm delighted that DataTables and Editor can help in some small way
Allan
British understatement, I guess. But I like it
One of the features that make such a big difference for my clients is that you can show / hide / prefill fields depending on the context. I use "dependent" over 300 times in my current solution. I also use it to load context-specific options for "select" fields. This makes life a lot easier for my clients because they only see relevant fields and not "everything": They can enter all details of a loan on one single screen for example, whereas competing solutions require opening three screens to do the same thing.
I knew you used
dependent()
a fair amount, but hadn't clicked it was quick as much as that! It was a method that came about from a chat with another dev who was using Editor - I almost suggested that he just use event listeners, but I sure am glad I brought it into the library. Amazing how little things can add up :-)Currently planning Editor 2.4 changes - hopefully there will be a few things to smile about there as well .
Allan