Editor Edit all selected rows and submit
Editor Edit all selected rows and submit
jmccolgan93
Posts: 13Questions: 8Answers: 0
in Buttons
hey,
I built a custom button to get all the selected rows and change the value of a column based on another. it works great but I can't get it to submit multiple lines I have multiple selected.
is there a better way to do this or am I just missing something here.
{
text: "Return",
editor: editor,
className: "mb-2 btn btn-small btn-primary",
enabled: false,
action: function (e, dt, node, config) {
let rows = dt_fixedheader.rows(".selected");
console.log("# of selected=" + rows.data().length); //it shows number of selected row
if (rows.data().length > 0) {
rows.every(function (rowIdx, tableLoop, rowLoop) {
console.log(rowIdx, tableLoop, rowLoop)
editor.edit(dt_fixedheader.row(rowIdx), false).set("checkedin", editor.get("checkedout")).submit();
});
}
},
}
Answers
You need to use the multi-row editing API to do what you are looking for.
Rather than calling
edit()
on each row, pass all the rows to a singleedit()
call, and then using the multi-row editing API to adjust the values as needed. Then you can submit the whole lot together.There are a couple of issues doing it as one edit call per row:
Multi-row editing is the way to go
Allan