Created
September 15, 2011 01:54
-
-
Save krams915/1218331 to your computer and use it in GitHub Desktop.
Event Table (jQGrid version) - add function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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