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 8440963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:26:32+00:00 2026-06-10T08:26:32+00:00

I’m working on a Django project which uses JQgrid to display data from the

  • 0

I’m working on a Django project which uses JQgrid to display data from the db.

What I’m looking to achieve is to have only the search option wired to perform a remote search where the server will return a result set and every other jqgrid option like column-sorting, pagination etc. to be performed client side.

I know this can be done by setting loadonce:true and toggling the 'datatype' parameter between 'local' and 'json' based on the .click() event depending on whether I click sort or next-page, search, etc.

Is there another way to do this? And if not, can you guys suggest a clean way of doing the above hack.

Thanks!

  • 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-06-10T08:26:33+00:00Added an answer on June 10, 2026 at 8:26 am

    I managed to get this done and I’m glad to share this with the rest of you all. I’ve posted my entire jqgrid code below the explanation for your reference.

    So firstly, I use JSON for my results and therefore the jsonReader.

    Next, following are the settings that are specific to achieving the {{search: remote},{sorting: local}, {pagination: local}} behavior.

    1. Set loadonce: false or else hitting the Search button will not hit the server and instead will always do a local search.

    2. I wanted to implement jqGrid’s multiple-search feature and therefore to have the tiny ‘magnification-glass’ appear in your pager bar..

      jQuery("#list2").jqGrid('navGrid','#pager2',{ del:false,add:false,edit:false},{},{},{},{multipleSearch:true});
      
    3. Now how I achieve the remote search feature is by toggling the datatype from local to json on the onSearch and onClose event. i.e. On firing a search query (i.e. clicking the ‘Find’ button) I set the loadonce to false and datatype to json. This ensures a remote search.
      Now that our grid is populated with remote-searched-data, we have to switch back to datatype:local, however explicitly setting it onClose doesn’t work, so instead i set loadonce: true which later sets datatype: local itself later.
      Also notice that I have closeAfterSearch: true, closeOnEscape: true, so that I ensure that the onClose event is always closed after firing a search query.

      jQuery("#list2").jqGrid('searchGrid', {multipleSearch: true, closeAfterSearch: true, closeOnEscape: true,
                                                          onSearch: function(){$("#list2").setGridParam({loadonce: false, datatype: 'json'});
                                                                                          $("#list2").trigger("reloadGrid");                                  
                                                                                          },                                                              onClose: function(){$("#list2").trigger("reloadGrid");                                                                                  
                                                                                      $("#list2").setGridParam({loadonce: true});
                                                                                      $(".ui-icon-refresh").trigger('click');                                                                                 
                                                                                      }
                                                      });
      

    The $(".ui-icon-refresh").trigger('click'); forces a refresh after loading the results. This was necessary in some cases (don’t know why). I just stumbled into this fix by myself and I’m not sure why it works. I’d love to know the reason behind it though if you have an idea.

    1. Lastly, everytime my grid loaded the search box would be popped by default. So I forced a close on it by simply having jquery click on the ‘x’ button of the modal box. Hacky but works! 😛

      $(".ui-icon-closethick").trigger('click');
      

    <<< Entire jqGrid code >>>

    Kindly excuse me for the ‘xyz’s in the code. I had some Django code in there and so I just replaced it with xyz to avoid any confusion.

    jQuery(document).ready(function(){ 
    
      $("#list2").jqGrid({
    
        url:'xyz',
        datatype: 'json',
        loadonce: false,
        mtype: 'GET',
        colNames:xyz
        colModel :xyz,
        jsonReader : {
                    repeatitems: false,
                    root: "rows",
                    page: "page",
                    total: "total",
                    records: "records"
            },
        height: '100%',
        width: '100%',
        pager: '#pager2',
        rowNum:15,
        rowList:[10,15,30],
        viewrecords: true,
        caption: '&nbsp',
         autowidth: false,
         shrinkToFit: true,
         ignoreCase:true,
         gridview: true
    
       });
      jQuery("#list2").jqGrid('navGrid','#pager2',{ del:false,add:false,edit:false},{},{},{}, {multipleSearch:true});
      jQuery("#list2").jqGrid('navButtonAdd', '#pager2',
                             {
                                 caption: "", buttonicon: "ui-icon-calculator", title: "choose columns",
                                 onClickButton: function() {
                                     jQuery("#list2").jqGrid('columnChooser');
                                }
                             });
      jQuery("#list2").jqGrid('searchGrid', {multipleSearch: true, closeAfterSearch: true, closeOnEscape: true,
                                                            onSearch: function(){$("#list2").setGridParam({loadonce: false, datatype: 'json'});
                                                                                            $("#list2").trigger("reloadGrid");                                  
                                                                                            }, 
    
                                                            onClose: function(){$("#list2").trigger("reloadGrid");                                                                                  
                                                                                        $("#list2").setGridParam({loadonce: true});
                                                                                        $(".ui-icon-refresh").trigger('click');                                                                                 
                                                                                        }
                                                        });
    
    
      $(window).bind('resize', function () {
        clearTimeout(resizeTimer);
        resizeTimer = setTimeout(resizeGrids, 60);
        divwidth = $(".content-box-header").width() - 40;
        //alert(divwidth);
       $("#list2").setGridWidth(divwidth,true);
    
        }); 
    
        $(window).resize();
        $(".ui-icon-closethick").trigger('click');
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have some data like this: 1 2 3 4 5 9 2 6
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

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.