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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:53:26+00:00 2026-05-21T10:53:26+00:00

function clearJqGrid() { // get IDs of all the rows of jqGrid var rowIds

  • 0
function clearJqGrid()
        {
            // get IDs of all the rows of jqGrid
            var rowIds = $('#messages').jqGrid('getDataIDs');
            // iterate through the rows and delete each of them
            for(var i=0,len=rowIds.length;i<len;i++)
            {
                var currRow = rowIds[i];
                $('#messages').jqGrid('delRowData', currRow);
            }   
        }

So I run this every singe time BEFORE i make an AJAX call to fill this grid. However, if you then go up and sort one of the columns, the grid is then bringing back all the old messages that were in it from the previous fill. Without sorting, you only see the ones that should be there.

Is the Jqgrid caching its entries when it shouldn’t be? Should my clearJqGrid() method be something else? I just made it this because I found it online, but do any of you have a better one?

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-05-21T10:53:26+00:00Added an answer on May 21, 2026 at 10:53 am

    The most effective way to remove all local data from the grid could be the code:

    // get DOM element of the table
    var myGridDomNode = $('#messages')[0];
    
    // delete internal local grid data 
    myGridDomNode.p.data = [];
    myGridDomNode.p._index = {};
    
    // delete all grid contain excepting the first dummy invisible row
    var trf = $("tbody:first tr:first",myGridDomNode)[0]; // save first row
    $("tbody:first",myGridDomNode).empty().append(trf);
    

    In other situations the GridUnload() can be effective used which destroy additionally the column headers, pager and all grid elements. So to display the grid one more time you will need recreate it.

    In the most cases you don’t need delete the grid contain. After the ajax call will be completed the jqGrid will delete the grid contain itself. Only if you switch manually the datatype of grid from dytatype:'json' to dytatype:'local' and back you can need to do this.

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

Sidebar

Related Questions

function text_window() { var xmlDoc; if (window.XMLHttpRequest) { xmlDoc=new window.XMLHttpRequest(); xmlDoc.open(GET,cd_catalog.xml,false); xmlDoc.send(); xmlDoc=xmlDoc.responseXML; }
function genTask(elem){ elem.each(function(){ $this=$(this).parent('.cntTasks'); var pattern=/taskId-(.*)$/ var idTask=$this.attr('id').match(pattern); var data='id_task='+idTask[1]; if(typeof jsVar2 !='undefined') data+=jsVar2;
function getNewMessages(id) { clearJqGrid(); var lat; var lng; var jsonData; var geocoder = new
function countChars(elm) { if (elm.nodeType == 3) { // TEXT_NODE return elm.nodeValue.length; } var
function example(){ var quantity = http://www.example.com/index.php?brandid=b%123&quantity=20; quantity = quantity.replace(-what regular expression should i user-,
function dowork() { $(.wrappedElement).removeClass(wrappedElement); $(.wrappedElementout).removeClass(wrappedElementout); var a=$(div#DepPart select option:selected).val(); $(div#TestPart select option[value^=a]).addClass(wrappedElement); $(div#TestPart select
function controllaFoto(target, username) { var _URL = window.URL || window.webkitURL; var img = new
function logsig() { var username = $(#username).val(); var password = $(#password).val(); var dataString =
function averageCalculator (numvalues) { for(i=0, i <= numvalues, i++>) { var score = prompt(input
Function calculate_attribute does not return a value; it only works through side effects. Often

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.