2012-08-23 62 views
5

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

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

回答

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

+0

感谢fbfcn它为我工作。 – user1516871

1

下面的代码片段将解决您的用途:

$('#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 
);