jqGrid - 默认添加/编辑按钮 - 处理服务器响应 [英] jqGrid - Default Add/Edit buttons - Processing Server Response
问题描述
我正在第一次实现 jqGrid.我正在使用出现在 navGrid 中的标准添加/编辑按钮,但是当我在编辑/添加表单中单击提交时,我无法识别如何处理服务器响应.
I am working on my first implementation of a jqGrid. I am using the standard add/edit buttons that appear in the navGrid but am having problems identifying how process the server response when I click Submit in the edit/add forms.
.navGrid("#product-codes-footer",{edit:true,add:true,del:false},
{afterShowForm:afterShowEdit}, {afterShowForm:afterShowAdd} );
我是否在某处缺少与此相关的标准回调或事件参数?有没有办法定义如何调用 saveRow
或者我可以实现默认的成功/错误回调方法?
Is there a standard callback or event parameter I am missing somewhere regarding this? Is there a way to define how saveRow
is called or is there a default success/error callback method I can implement?
任何方向都将不胜感激!!!
Any direction would be much appreciated!!!
推荐答案
似乎有几个事件参数我没有完全阅读和理解...
There appears to be a couple event parameters that I failed to completely read and comprehend...
API --> http://www.trirand.com/jqgridwiki/doku.php?id=wiki:form_editing#editgridrow
使用 afterSubmit 和 afterComplete 的事件参数允许我处理服务器响应并更新表单.
using the event parameters for afterSubmit and afterComplete allow me to process the server response and update the form.
--丹
编辑这是使用的代码示例...
EDIT Here is an example of the code used...
.navGrid(
"#product-codes-footer",
{edit:true,add:true,del:false},
{
afterShowForm:afterShowEdit,
afterSubmit:processAddEdit,
beforeSubmit:validateData,
closeAfterAdd: true,
closeAfterEdit: true
},
{
afterShowForm:afterShowAdd,
afterSubmit:processAddEdit,
beforeSubmit:validateData,
closeAfterAdd: true,
closeAfterEdit: true
}
);
function afterShowEdit(formId) {
//do stuff after the form is rendered
}
function afterShowAdd(formId) {
//do stuff after the form is rendered
}
function processAddEdit(response, postdata) {
var success = true;
var message = ""
var json = eval('(' + response.responseText + ')');
if(json.errors) {
success = false;
for(i=0; i < json.errors.length; i++) {
message += json.errors[i] + '<br/>';
}
}
var new_id = "1";
return [success,message,new_id];
}
这篇关于jqGrid - 默认添加/编辑按钮 - 处理服务器响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!