Skip to content

Instantly share code, notes, and snippets.

@krams915
Created September 15, 2011 01:54
Show Gist options
  • Save krams915/1218331 to your computer and use it in GitHub Desktop.
Save krams915/1218331 to your computer and use it in GitHub Desktop.
Event Table (jQGrid version) - add function
function addRow() {
// Get the currently selected row
$("#grid").jqGrid('editGridRow','new',
{ url: "${rootUrl}jqgrid/event/add",
serializeEditData: function(data){
data.id = 0;
data.date = new Date(data.date).toISOString();
return $.param(data);
},
recreateForm: true,
closeAfterAdd: true,
reloadAfterSubmit:true,
beforeShowForm: function(form) {
$("#date").datepicker({
changeMonth: true,
changeYear: true
});
},
afterSubmit : function(response, postdata)
{
var result = eval('(' + response.responseText + ')');
var errors = "";
if (result.success == false) {
for (var i = 0; i < result.message.length; i++) {
errors += result.message[i] + "<br/>";
}
} else {
$("#dialog").text('Entry has been added successfully');
$("#dialog").dialog(
{ title: 'Success',
modal: true,
buttons: {"Ok": function() {
$(this).dialog("close");}
}
});
}
// only used for adding new records
var new_id = null;
return [result.success, errors, new_id];
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment