Copy button on every row of grid
Confluence User - 02 Aug, 2020
We are trying to add a "copy button on every row of the grid". As opposed to a single button. This would be a variation of the https://dev.joget.org/community/display/DX7/Duplicate+Form+Grid Copy Grid 1 to Grid 2" a sample script that helps us copy all rows with a single button click.
The Usecase that I am trying to Handel is after coping with the Rows to the destination Grid the source grid data is updated. and instead of coping with all rows, only the updated one will be copied over.
Not sure how to inject this into grid ?
<td><input type='button' class='cpRow' value='Copy Row Grid1 to Grid2'></td></tr>
<script>
$(function(){
$(".cpRow").on("click", function() {
var grid1 = FormUtil.getField("field1");
var grid2 = FormUtil.getField("field2");
$(grid1).find(".grid-row"){
var json = $(this).find("textarea").val();
//remove id
var obj = JSON.parse(json);
if (obj.id !== undefined) {
delete obj.id;
json = JSON.stringify(obj);
}
$(grid2).enterpriseformgrid("addRow", {result: json });
});
});
});
</script>
forms;javascript