Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6324351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:41:11+00:00 2026-05-24T16:41:11+00:00

I am newbie in using jqgrid. While new page load the grid is properly

  • 0

I am newbie in using jqgrid.

While new page load the grid is properly loading the data from database. Afterwards due to loadonce: true the grid is not reloading the data from database for add/edit/delete.

My application combination is JSP, Servlet, MySQL

I have a grid with following settings

jQuery("#userList").jqGrid({
                    url: '<%=request.getContextPath()%>/userJqGrid?q=1&action=fetchData&userCookie=<%= encodedCookie%>',
                    datatype: 'xml',
                    mtype: 'GET',
                    colNames:['<%= userProp.getProperty(userColNames[0])%>',
                              '<%= userProp.getProperty(userColNames[1])%>',
                              '<%= userProp.getProperty(userColNames[2])%>',
                              '<%= userProp.getProperty(userColNames[3])%>',
                              '<%= userProp.getProperty(userColNames[4])%>',
                              '<%= userProp.getProperty(userColNames[5])%>'
],
                    colModel:[
                        {name:'<%= userColNames[0]%>',index:'<%= userColNames[0]%>',
                            width:120,sortable:true,editable:true,editrules:{required:true},formoptions:{rowpos:1, elmprefix:'*'}},
                        {name:'<%= userColNames[1]%>',index:'<%= userColNames[1]%>',
                            width:130,sortable:true,editable:true},
                        {name:'<%= userColNames[2]%>',index:'<%= userColNames[2]%>',
                            width:100,sortable:true,editable:true,editrules:{required:true},formoptions:{rowpos:3, elmprefix:'*'}},
                        {name:'<%= userColNames[3]%>',index:'<%= userColNames[3]%>',
                            width:180,sortable:true,editable:true,editrules:{email:true,required:true},formoptions:{rowpos:4, elmprefix:'*'}},
                        {name:'<%= userColNames[4]%>',index:'<%= userColNames[4]%>', 
                            width:100,sortable:true,editable:true},
                        {name:'<%= userColNames[5]%>',index:'<%= userColNames[5]%>', 
                            width:100,sortable:true,editable:true},
                    ],
                    pager: '#pager1',
                    rowNum:50,
                    height:'auto',
                    //rowList:[10,20,30],
                    loadonce: true,
                    sortname:'<%= userColNames[0]%>',
                    viewrecords: true,
                    editurl:'<%=request.getContextPath()%>/userJqGrid?q=1&action=addData&userCookie=<%= encodedCookie%>',
                    caption: 'User Grid',
                    ondblClickRow: function(rowid) {
                       $("#userList").jqGrid('editGridRow',rowid, userEditParam);
                        return;
                    }
                 });
$("#userList").jqGrid('navGrid',"#pager1",{add:true,edit:true,del:true});
$("#userList").jqGrid('gridResize', { minWidth: 450, minHeight: 150});

I tried adding following code to reload

$("#userList").jqGrid('setGridParam',{datatype:xml}).trigger('reloadGrid')

Can some one help?

Solution which worked for me

$("#userList").jqGrid('navGrid',"#pager1",{add:true,edit:true,del:true,refresh:true,

beforeRefresh: function() {
   $("#userList").jqGrid('setGridParam',{datatype:xml}).trigger('reloadGrid');
}},
{
  afterSubmit: processAddEdit,
       closeAfterAdd:true,
       closeAfterEdit:true
},{
  aftersubmit:processAddEdit,
       closeAfterAdd:true,
       closeAfterEdit:true
});

function processAddEdit() {
  $("#userList").jqGrid('setGridParam',{datatype:xml}).trigger('reloadGrid');
  return[true,'']; //no error
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T16:41:14+00:00Added an answer on May 24, 2026 at 4:41 pm

    Correct is datatype:'xml' and not datatype:xml. So the code like

    $("#userList").jqGrid('setGridParam', {datatype:'xml'})
                  .trigger('reloadGrid', [{page:1}]);
    

    should work. See here for description of additional parameters of reloadGrid.

    UPDATED: From your comments I hope that I know where you have problem with the implementation. If I understand you correct now you want that “Reload Grid” button from the navigator bar reloads the grid from the server. To do so you should redefine the standard “Reload Grid” button with your implementation which do the code which I included in my answer (see above). So you should use refresh: false as the navGrid option to remove the standard “Reload Grid” button and then use navButtonAdd to add new button which looks exactly like the standard button and have your custom implementation or the onClickButton event:

    var myGrid = $('#userList');
    myGrid.jqGrid({
        datatype: 'xml',
        loadonce: true,
        pager: '#pager1',
        // ... other parameters which you use
    });
    myGrid.jqGrid('navGrid', '#pager1', {refresh: false});
    myGrid.jqGrid(
        'navButtonAdd',
        '#pager1',
        {
            caption: "",
            buttonicon: "ui-icon-refresh",
            title: $.jgrid.nav.refreshtitle,
            onClickButton: function () {
                $(this).jqGrid('setGridParam', {datatype:'xml'});
                $(this).trigger('reloadGrid', [{page:1}]);
            }
        }
    );
    

    UPDATED 2: To force reloading of the grid after Add and Edit operations you can use afterSubmit event which will be called after the receiving successful server response, but before reloadGrid made by the jqGrid.

    myGrid.jqGrid('navGrid', '#pager1', {refresh: false},
        { // Edit options
            afterSubmit: function () {
                $(this).jqGrid('setGridParam', {datatype:'xml'});
                return [true,'']; // no error
            }
        },
        { // Add options
            afterSubmit: function () {
                $(this).jqGrid('setGridParam', {datatype:'xml'});
                return [true,'',false]; // no error and no new rowid
            }
        },
        { // Delete options
            afterSubmit: function () {
                $(this).jqGrid('setGridParam', {datatype:'xml'});
                return [true,'']; // no error
            }
        }
    );
    

    I am not sure that reloading of the grid from the server is really required after Edit and Delete operations in general, but reloading after the Add operation could be needed if the server not returns the new id in the server response. You can set reloadAfterSubmit: false and return the new id in the server response. See this and this answers for details.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a newbie using Java to do some data processing on csv files.
Newbie question... I am using silverlight to POST data to my GAE application class
I'm a newbie to using SSIS for data imports - I have a couple
A newbie question - I'm using [NSUserDefaults standardUserDefaults] to store user specified preferences. While
Newbie question. Pylons 1 + SQLA using declarative style. New to Python. I have
newbie writing, I'm new to MVC 2 C# and using EntityFramework with LINQ. In
I am newbie for hibernate,i am using mysql database,with two tables serviceTypeDetails,validateConfig.In serviceTypeDetails,it's having
I've done an example using bitarrays from a newbie manual. I want to know
Being a newbie to using matplotlib ,I was trying out some code ,from examples
Newbie disclaimer: I am new to Python and just started using IDLE to play

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.