Different data between form and table
Different data between form and table
Hey Alan,
Working on something that is closely related to the example here (https://editor.datatables.net/examples/advanced/tableOnlyData.html) and its inverse. The difference is that I need some overlapping fields between the two and then unique fields between the two.
The editing of an item can be done inline in the table. One of the options in a Select2 field (allows users to select a product from their catalog) is "Create New." On click I'm having it not submit the editor data but rather create().open()
How can I account for Editor's fields
option needing 1) the new item entry form's fields, 2) the table's inline editing fields?
Thanks for any thoughts-
This question has an accepted answers - jump to answer
Answers
As in you need to add a new field to the form? The
add()
method can be used to do that.I think you'll need to use the
columns.editField
option to tell Editor what field to edit for the column - otherwise you might edit the wrong field or get an error message about it not being able to determine what field to edit.Allan
Thanks, Alan.
My understanding of the above doesn't seem to solve things. On click of the "Create New" option in Select2 I'm kicking off the new item Editor form:
The
newFields
array has all of the fields I'd want and need to create a new product. These fields are different in some cases than the Datatable's fields, but also has some that are the same.To avoid confusion and complexity, though, I just gave all of the
newFields
fields differentname
properties. My hope was simply to subdivide the work and thus avoid conflicts. Allow inline to handle what's loaded in DT and the new product form to communicate with the server and then use the returned json to fill in the row being edited w the new information.The form shows up great now...but only the first time :\ After that it has a conflict because it's adding fields of the same name. As a result, I've also attempted to get things taken care of by hiding all fields and then showing just those that I want. This fails bc of the fields not existing in the Datatable data.
I'm beginning to think that if there is a solution it will ultimately be too hacky to be worthwhile and that a custom solution of sorts is required. Would you agree or have any insight on how to get this accomplished?
Can you simply check to see if the field is present before adding it? The
field()
method should let you do that, ororder()
.You could also remove the added field using
clear()
when the form is closed (close
) if you want the user to be able to add it again in future.Allan
This looks promising. Going to try it out and report back.
beautiful!
the select2's
onChange
:and the
editor.close
:Thanks!