I have a very basic jqGrid table (#list) which contains a column: actions. I somehow figure out how to add custom functions but don't know how to generate the code to duplicate its content (if possible using addrowData method). Here is my code so far:
(...)
gridComplete: function () {
var grid = jQuery("#list");
var ids = grid.jqGrid('getDataIDs');
//console.log(ids);
for (var i = 0; i < ids.length; i++) {
var rowId = ids[i];
var cbutton = "<input style='height:22px;width:75px;' " + "type='button' value='Duplicate' " + "onclick=\"Duplicate('#list'," + rowId + ");\" />";
grid.jqGrid('setRowData', rowId, {
action: cbutton
});
}
(...)
and the custom function Duplicate:
Duplicate = function (table, Id) {
console.log(table);//#list
console.log(Id);//whatever row Id clicked
//need a way to duplicate the row
}
I guess I might pass all values to the function as arguments, create a new Row using addrowData and then perform a foreach to fill in the rows with data (myData).
Any clues?