在jqgrid中提交后如何关闭表格并重新加载网格? [英] How to close form and reload grid after submit in jqgrid?

查看:219
本文介绍了在jqgrid中提交后如何关闭表格并重新加载网格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了很多关于我的问题的答案,并且可以正确地做到这一点,但是由于某些人有这样的问题,所以我的问题没有解决.即,单击提交按钮后,我的表格不会消失. 我使用以下代码:(我想我的问题很小,但我无法解决,请帮助我)

I found many response about my question and do that correctly, but as somebodies have such problem, my problem does not solved. i.e. my form does not disappear after click on submit button. I use this code: (I guess my problem is tiny but i can not solve it, Please help me)

$(function(){
$("#grid").jqGrid({
url:'example.php',
datatype: 'xml',
mtype: 'POST',
colNames:['Inv No','Date', 'Amount','Tax','Total','Notes'],
colModel :[ 
  {name:'invid', index:'invid', width:55, align: 'center'}, 
  {name:'invdate', index:'invdate', width:90, align: 'center'}, 
  {name:'amount', index:'amount', width:80, align:'center',editable: true}, 
  {name:'tax', index:'tax', width:80, align:'center',editable: true}, 
  {name:'total', index:'total', width:80, align:'center'}, 
  {name:'note', index:'note', width:150, sortable:false} 
],
height: 'auto',
width: 'auto',
editurl: "edit.php",
pager: '#pager',
rowNum:10,
cellEdit: true,
cellsubmit: 'remote',
cellurl: 'edit.php',
ondblClickRow: function(id, status) {
    //var pageNumber = jQuery("#grid").getGridParam('rowNum');
    //jQuery("#grid").editGridRow(id);
    alert(id);
},
afterSubmitCell: function(response) {
    if(response.responseText == "ERROR")
        alert('Zekki');
},
beforeSubmitCell: function() {
    alert('before'); 

},
rowList:[10,20,30],
sortname: 'invid',
sortorder: 'asc',
viewrecords: true,
gridview: true,
caption: 'My first grid',
multiselect: true,
multikey: 'ctrlKey',
toolbar: [true,'bottom'],
loadComplete: function () {
    //alert("OK");
},
loadError: function (jqXHR, textStatus, errorThrown) {
    alert('HTTP status code: ' + jqXHR.status + '\n' +
          'textStatus: ' + textStatus + '\n' +
          'errorThrown: ' + errorThrown);
    alert('HTTP message body (jqXHR.responseText): ' + '\n' + jqXHR.responseText);
}
}).navGrid('#pager',{edit:true,add:true,del:true},
    {
        afterSubmit:processAddEdit,
        closeAfterAdd: true,
        closeAfterEdit: true,
        reloadAfterSubmit:true,
    }, 
    {
        afterSubmit:processAddEdit,
        closeAfterAdd: true,
        closeAfterEdit: true,
        reloadAfterSubmit:true,
    }, 
    {
        afterSubmit:processAddEdit,
        closeAfterAdd: true,
        closeAfterEdit: true,
        reloadAfterSubmit:true
    }).filterToolbar();
function processAddEdit(response, postdata) {
    alert("* "+response.responseText+" *");
}
    /*var pageNumber = jQuery("#grid").getGridParam('page');
    var rowNumber = jQuery("#grid").getGridParam('rowNum');
     */

});

谢谢 最好的问候

推荐答案

我遇到了类似的问题,但是尝试手动关闭表单,我确定这不是最好的做法,但是还是可以的.

I had a similar problem but tried closing the form manually, I'm sure this is not the best thing to do but it works anyway.

尝试将其添加到代码中

function processAddEdit(response, postdata) {
   alert("* "+response.responseText+" *");
   $(".ui-icon-closethick").trigger('click');
}

最好在关闭表单之前评估是否没有错误.

It is better to evaluate whether there is no error before closing the form anyway.

这篇关于在jqgrid中提交后如何关闭表格并重新加载网格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆