duplicate record combined with inline.create and our compound key
duplicate record combined with inline.create and our compound key
MadMax76
Posts: 149Questions: 33Answers: 1
I have these buttons in my in my datatable:
buttons: [
{ extend: "create", editor: editor_pos, text: "Neue Position" },
{ extend: "edit", editor: editor_pos },
{ extend: "selected",
text: 'Duplicate',
action: function ( e, dt, node, config ) {
// Start in edit mode, and then change to create
editor_pos
.edit( table.rows( {selected: true} ).indexes(), {
title: 'Duplicate record',
buttons: 'Create from existing'
} )
.mode( 'create' ); } },
{ extend: "remove", editor: editor_pos },
{
extend: "createInline",
editor: editor_pos,
formOptions: {
submitTrigger: -2,
submitHtml: '<i class="fa fa-play"/>'
}
}
]
I would love the "duplicate" also to happen "inline" like the 4th button. But: Additionally one field (that I would like to hide) would have to be changed due to a compound key... it should be max of this field plus one.
Thanks
Max
Answers
Hi Max,
Absolutely
inlineCreate()
can be done. Here is an example.It works fairly easily in that example due to the 1:1 mapping between the fields and data in the table, that might need to be modified it your case, it might not. And you have control over every field as you will see, so you can disable one field, set it to blank or whatever as required.
Allan
Thanks! I can not rtick this as answered, but it is!!!
Max
Hi Allan,
in my table I have separate fields for data shown and the editfield.
If I do any changes, always the value from the shown field shall be used for any operation.
Therefore I have e.g. this functon in there
And here comes the problem / question: The function used in your example copies the data from the "editfield", not from the "data".
In the end I would EITHER need to do this init-edit-funciotn before copying the line, OR copy the data-value straight away.
Is any of them possible?
Thanks Max
Only threads which are opened with "Ask a question" can be marked as such. "New Discussion" can't. I've moved this one over now though. Hopefully one more for my tally .
This is local editing is it (i.e. not submitting to the server)? What you really want is for the data object for each row to contain both the label you show to the end user, and the reference value that points to the joined id.
Have a look at this example which shows how joined data can be done with local editing, when you have both the label and the value available.
Regards,
Allan