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

  • Home
  • SEARCH
  • 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 9015651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:48:08+00:00 2026-06-16T03:48:08+00:00

So, I’ve got an implement of jqGrid which is working great. I’m displaying some

  • 0

So, I’ve got an implement of jqGrid which is working great. I’m displaying some rows of data and when new data is added — the grid refreshes as appropriate.

However, if I try and drop a row from the grid — it doesn’t cleanup the missing rows! Adding new rows is fine, but deleting leaves data and bugs out the grid’s display.

If I call ‘clearGridData’ first, I see the data cleaned up as appropriate. However, if I call clearGridData — I lose my selection/page!

http://jsfiddle.net/yNw3C/1766/

var data = [[48803, "DSK1", "", "02200220", "OPEN"], [48769, "APPR", "", "77733337", "ENTERED"]];

$("#grid").jqGrid({
    datatype: "local",
    height: 250,
    colNames: ['Inv No', 'Thingy', 'Blank', 'Number', 'Status'],
    colModel: [{
        name: 'id',
        index: 'id',
        width: 60,
        sorttype: "int"},
    {
        name: 'thingy',
        index: 'thingy',
        width: 90,
        sorttype: "date"},
    {
        name: 'blank',
        index: 'blank',
        width: 30},
    {
        name: 'number',
        index: 'number',
        width: 80,
        sorttype: "float"},
    {
        name: 'status',
        index: 'status',
        width: 80,
        sorttype: "float"}
    ],
    caption: "Stack Overflow Example"
});

var names = ["id", "thingy", "blank", "number", "status"];
var mydata = [];

for (var i = 0; i < data.length; i++) {
    mydata[i] = {};
    for (var j = 0; j < data[i].length; j++) {
        mydata[i][names[j]] = data[i][j];
    }
}

for (var i = 0; i <= mydata.length; i++) {
    $("#grid").jqGrid('addRowData', i + 1, mydata[i]);
}

$('#UpdateGridButton').click(function(){
    mydata[0].status = "CLOSED";
    delete mydata[1];

    //If I add this -- I can refresh grid data properly, but I lose my selection.
    //$('#grid').clearGridData();

    $("#grid").jqGrid('setGridParam', { data: mydata});

    $("#grid").trigger('reloadGrid', [{current: true}]);
});

​
Is the best of both worlds supported implicitly by jqGrid? Or do I need to write custom logic?

  • 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-16T03:48:09+00:00Added an answer on June 16, 2026 at 3:48 am

    Sorry, but you use jqGrid in wrong way currently.

    First of all the filling of the grid is very important. You use currently addRowData. It’s the oldest, but the slowest way to fill the grid which I know. If you use datatype: "local" you should use data: mydata which allows to create directly jqGrid with the data.

    Other very important options are gridview and rowNum. You should always use gridview: true to improve performance of grid (see the answer for more details). To understand the value of rowNum you should know that jqGrid is designed to support paging of data. In case of datatype: "local" sorting and paging will be implemented locally by jqGrid itself. The pager for navigation through pages will be created either by usage of toppager: true option or by usage pager: "#pagerId". Even if you don’t create any pager local paging is still activated. Default value of rowNum is 20. So your current grid will display just the first 20 rows. the only exception if addRowData which force adding the row on the current page temporary. After reloading (for example indirectly by changing the sorting) only the first 20 rows will be shown for the user and the user will have no GUI to change the page (!!!???). If you want to display all rows on one page you should use rowNum: 10000 for example.

    The next important parameter is autoencode: true which mean that the data for the cells should be interpreted as text and not as HTML fragment. If you don’t use autoencode: true you will be unable to display the text which contain '<', '>', '&' and so on.

    I recommend you additionally to use height: "auto" if you use local paging of data. It will remove empty space on the right size of the grid reserved for the scrollbar. You can use alternatively scrollOffset: 0 to remove the unneeded space.

    The next important error in your code is the usage of setGridParam with data parameter. You cab do this only if the grid was empty before or if you need to add some additional rows. The setGridParam exist mostly for other purpose. It uses internally $.extend (see the code here). So you will extend the old contain of data with new values instead of replacing old data to new one. What you can do is for example to use getGridParam to get the reference to internal data parameter:

    var data = $("#grid").jqGrid("getGridParam", "data");
    

    Then you can modify array data using push, pop and delete. To full replace the data you can do

    var allParameters = $("#grid").jqGrid("getGridParam");
    allParameters.data = newData; // or newData.slice(0)
    

    After that you can reload the grid by triggering of "reloadGrid".

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have an autohotkey script which looks up a word in a bilingual dictionary

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.