添加对话框后没有关闭

时间:2012-08-23 12:59:07

标签: jqgrid

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

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"});

2 个答案:

答案 0 :(得分:9)

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

添加:

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

编辑:

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

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

{url: "category/updatecategory", closeAfterEdit: true}, 
{url: "category/createcategory", 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
},

这些设置可在wiki

上找到

答案 1 :(得分:2)

以下代码段将解决您的目的:

$('#toolbar1').jqGrid('navGrid', '#toolbar1_toppager', 
            {edit:true,add:true,del:true,search:false}, // options
            {closeAfterEdit:true}, // edit options
            {closeAfterAdd:true},  // add options
            {},   //del options
            {},  // search options
);