Standalone edition : edit() by id
Standalone edition : edit() by id
Hi,
I'm looking for a way edit a specific record (lets says with id #7) by clicking on a link (there is no table on my page).
I closely read the following from the edit() documentation:
Standalone editing - Not required. Standalone editing cannot use multiple form sources like DataTables editing, a single Editor instance refers to a single configuration set in the database, so this option is not required, however, it can still be provided to give identification information to the server. Whatever value is given here will be passed to the server as the id parameter. Use null if you want to provide the other parameters (show and options) and do not require a value to be given.
So, to my understanding I could do such thing in js as :
non_conformity_editor.edit(7)
and it would edit record with id #7? Actually it opens the editor modal but with empty records.
Many thanks!
Sébastien
This question has accepted answers - jump to:
Answers
Well,
there must be something I missed in my understanding on how things work.
I tried doing so:
and actually everything works.
I'll some more docs to understand why!
Hi Sébastien,
It will need edit row id 7 (assuming the server-side script is setup to handle the request). However, if the form in the data is showing as empty, that suggests that the field values are not already present in the HTML for the form to display.
If you look at this example you will see that the values are in the HTML. Editor does not make an Ajax request to get the values based on the row id.
Allan
Hi Allan,
as always, many thanks for your answer.
I worked this afternoon on this to try to find a good solution that matches my needs but I'm kind of stuck in my process
My actual situation is the following:
a list of issues related to this product (stored in the "issues") table --> OK
My problem is that my "issue" table is not displayed on my page when I work on products and therefore I can not access it (or its data) from my "product" editor window (what I mentioned as success was a bug displaying the two tables on the same page).
I made a specific Ajax request to get the "issue" records related to a specific product:
{"data":[{"DT_RowId":"row_7","id":"7","product":"0728 - 1","date":"09\/01\/2018 22:07","non_conformity_quantities":"100"},{"DT_RowId":"row_8","id":"8","product":"0728 - 1","date":"09\/01\/2018 22:07","non_conformity_quantities":"200"}]]
but from there I'm stuck with mixed feelings wondering if I don't have it all wrong.
Thanks again
If you don't have the data you want to edit already on the page - that's fine, but you do need to an extra step. You've loaded the data, so what you can do is use the Editor API to set those values (
val()
) - for example you might do:Allan
Just b r i l l i a n t !
Many thanks