Skip to content

Commit

Permalink
Workaround to copy selected val of options
Browse files Browse the repository at this point in the history
  • Loading branch information
Gomez committed Oct 7, 2019
1 parent b54293c commit 6fb00ae
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/collective/z3cform/datagridfield/static/datagridfield.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,14 @@ require([
$(all_select2[i]).select2('destroy');
}
//clone the row
var duplicatedRow = thisRow.clone();
var duplicatedRow = thisRow.clone(true, true);
// Jquery does not clone selected of options, so this is needed:
// https://stackoverflow.com/questions/742810/clone-isnt-cloning-select-values
var selects = $(thisRow).find("select");
$(selects).each(function (i) {
var select = this;
$(duplicatedRow).find("select").eq(i).val($(select).val());
});
dgf.trigger("beforeaddrow", [dgf, duplicatedRow]);

// If using auto-append we add the "real" row before AA
Expand Down

0 comments on commit 6fb00ae

Please sign in to comment.