Jqgrid “添加后”对话框未关闭

Jqgrid “添加后”对话框未关闭,jqgrid,Jqgrid,下面是我的代码,提交后我需要关闭“添加/编辑”对话框。在这两种情况下,它都会更新服务器并重新加载网格,但不会关闭对话框: jQuery("#toolbar1").jqGrid({ url:'category/getcategorylist', datatype: "xml", colNames:["Name","Description","Id"], colModel:[ {name:"cname",index:"cname",edita

下面是我的代码,提交后我需要关闭“添加/编辑”对话框。在这两种情况下,它都会更新服务器并重新加载网格,但不会关闭对话框:

jQuery("#toolbar1").jqGrid({
     url:'category/getcategorylist',
     datatype: "xml",
     colNames:["Name","Description","Id"],
     colModel:[
         {name:"cname",index:"cname",editable:true, width:250, align:"center",xmlmap:"categoryName"},
         {name:"cdescription",index:"cdescription", editable:true,width:300, align:"center",xmlmap:"description"},
         {name:"id",index:"id", editable:true,width:210, align:"center",xmlmap:"categoryId",key: true,hidden: true},
     ],
     rowNum:100,
     viewrecords: true,
     toppager:true,
     height:250,
     width:800,
     modal:true,
     sortorder: "asc",
     xmlReader: {
        root : "CategoryList",
        row: "categoryList",
        repeatitems: false
     },
});
$("#toolbar1").jqGrid("navGrid", "#toolbar1_toppager", {
     reloadAfterSubmit:true, view: false, search:false ,addtext: 'Add',
     edittext: 'Edit',
     deltext: 'Delete',
     refreshtext: 'Reload'
},
{url: "category/updatecategory"}, {url: "category/createcategory"}, {url:"category/deletecategory"});

有一些用于关闭对话框的属性需要在编辑/添加声明中设置,它们通常默认为false

用于添加:

closeAfterAdd
-在添加模式下,在添加记录后关闭对话框。(默认值:false)

用于编辑:

closeAfterEdit
-在编辑模式下,编辑后关闭对话框。(默认值:false)

因此,在您的示例中,您需要:

{url: "category/updatecategory", closeAfterEdit: true}, 
{url: "category/createcategory", closeAfterAdd: true}
或:


以下代码片段中提供了这些设置,可以解决您的问题:

$('toolbar1').jqGrid('navGrid','toolbar1'u-toppager',
{edit:true,add:true,del:true,search:false},//选项
{closeAfterEdit:true},//编辑选项
{closeAfterAdd:true},//添加选项
{},//删除选项
{},//搜索选项
);
$("#toolbar1").jqGrid("navGrid", "#toolbar1_toppager", {
     reloadAfterSubmit:true, view: false, search:false ,addtext: 'Add',
     edittext: 'Edit',
     deltext: 'Delete',
     refreshtext: 'Reload',
     closeAfterAdd: true,
     closeAfterEdit: true
},