views:

236

answers:

1

I'm looking for recommendations for jqgrid to add a large dataset from a local source. Right now, there's a simple loop:

grid.clearGridData();
for(var i = 0; i < data.length; i++)
{
    grid.addRowData(i+1, data[i]);
}
grid.trigger(”reloadGrid”);

And on some larger data sets, this causes the browser to display the “javascript is using too many resources…quit/continue” message in IE and FF, usually after several “Continues” everything is fine. This is for data sets of ~2000 rows.

I can break this up into several chunks with setTimeout, but that feels kludgy.

Using version 3.3 of jqgrid.

+1  A: 

My first thought is that 2000 rows is usually far too many for a single page; users just won't be able to process that much information. If they do need it all at once for some reason, it might be worth exporting to CSV, since that usually makes it easier to do the sorts of things one would want to do on 2000 rows of data, e.g., arbitrary statistics.

My next thought is that if you still need to do this, you might try upgrading to the most recent version of jqGrid (currently 3.6.1) in the hopes that they've optimized this path a bit.

Another idea: if you're using JSON, have you tried configuring jqGrid to let the browser's native parsing handle parsing the JSON? It's documented here a little way down the page.

In general, setTimeout kludges are the way to fix this sort of thing if you really need it, but most of the time you're better off taking a step back and looking for a different solution to whatever problem you're solving.

Hank Gay
I think so too. This is an edge case in a much larger app, and it has to be handled gracefully somehow -- I can't switch gears for this case. Thanks for the JSON suggestion. I'll have to investigate and have to move some pre-processing that occurs on the data to somewhere else.
clintp
Hope it works out—I hate when random edge cases take up most of the dev time, but it seems to happen a fair bit.
Hank Gay
After 4 hours of work, I'm really fed up with jqgrid and will probably abandon it completely. I'm .3 revisions behind and upgrading isn't working at all: the UI is in tatters and ultimately .addJSONdata "is not a function" errors hound me. Going from local data to javascript object data isn't particularly easy and very poorly documented.
clintp
If you do wind up abandoning jqGrid, let me know what you went with instead. So far, it's the best grid widget I've found for jQuery, but I'd definitely be interested in hearing about a better one.
Hank Gay
I prefer jqgrid, but for local data processing, jquery datatables looks interesting (coworker prefers it for his ad-hoc reporting purporses)
r00fus