Don't understant the difference between using editor.edit() and using a button with editor:
Don't understant the difference between using editor.edit() and using a button with editor:
Is there a difference between using the datatable editor button, i.e
{
extend: 'edit',
text: 'Revise',
editor: editorRevise,
}
and calling an editor on the onclick of a field using <editor>.edit()?
Reason I ask, when using as datatable as an input and I use the extended button I get my values selected in my table.
When I use editor .edit() I get a message in my editor about multiple values. Is there something I'm missing? Do I need to set the values manually or do something more when using editor.edit()? I have included images as examples.
This question has accepted answers - jump to:
Answers
Effectively no - the
edit
button will call theedit()
method. However, it does so passing in title, buttons, etc to theform-options
.The multiple values message suggests that multiple rows might be selected - which could be the case if you just call
editor.edit()
without passing in a suitable row selector. Perhaps you can show me the code you are using?Allan
This is the code cut down from the original.
I'm also including a json file for the table and the data for the revise column the structure can be viewed. In the code, they are the return of the ajax calls for the data sources.
Sorry it's so long, I don't think I can cut it down much more, without losing the intent of the code.
Guess, I also must have missed something in the formatting of the code.
Allen, I think I got banned accidently by attempting to edit and save my code too many times in a row.
That will select edit only a single row.
This however will edit all rows (no specific row is selected - the selector is
undefined
). Is that really want you want - or should it use$(this).closest('tr')
as well?Thanks,
Allan
p.s. The formatting for code uses backticks, not single quotes. I've updated the posts above.
I really needed the closest row as shown on the first part of your post. Thank you. Lastly, is there a callback I can use in the edit that allows for the update of the table after the edit? Let me know if you would like me to start as a new thread on this..
Of the host table? As long as the JSON returned from the edit follows what Editor expects in return, then it should update the host table automatically. Is your server returning JSON in that format for the edit action?
Allan
Yes, of the host table. It currently is not returning the expected information, however a minor adjustment to the stored procedure will fix that. So unlike an ajax function, which has a successCallback, as long as the editor gets what it expects, it has it's own callback? As always, thank you for your help.
If you use
ajax
as a function, then you need to pass the JSON structure expected to thesuccessCallback
function. If you don't use it as a function, but just as a string or object, then it will automatically add its own callback to watch for the response from the server.Allan