After add dialog is not closing
Asked Answered
I

2

5

Below is my code, and I need to close the add/edit dialog after a submit. It's updating the server and reloading the grid in both the cases, but it is not closing the dialog:

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"});
Italic answered 23/8, 2012 at 12:59 Comment(0)
P
9

There are some properties for closing the dialog that needs to be set on your edit/add declarations, they normally default to false.

For Adding:

closeAfterAdd - when add mode, close the dialog after add record. (default: false)

For Editing:

closeAfterEdit - when in edit mode, close the dialog after editing. (default: false)

So in your example you would need:

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

Or:

$("#toolbar1").jqGrid("navGrid", "#toolbar1_toppager", {
     reloadAfterSubmit:true, view: false, search:false ,addtext: 'Add',
     edittext: 'Edit',
     deltext: 'Delete',
     refreshtext: 'Reload',
     closeAfterAdd: true,
     closeAfterEdit: true
},

These settings are available on the wiki

Plemmons answered 23/8, 2012 at 13:21 Comment(0)
S
2

Following code snippet will solve your purpose :

$('#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
);
Synodic answered 12/12, 2014 at 5:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.