3

I am using jqGrid in an ASP.NET page and injecting the datainto a script block on the page and then loading from there. For this one use case it is necessary that we have a large amount of data visible on the screen at once. which involves 300~500 records with 30 columns on each row. Paging for this case is not a good fit. The user needs to be able to scan the mass amount of data, select 40~60 rows and then move off to another screen.

I was unsure if this would be a good fit in the begging for jqGrid but in prototyping everything worked plenty fast enough. However moving to production it is painfully slow in the multi-select mode.

I have narrowed down the pain point to jQueryUI 1.8. If I revert just that back to jQueryUI 1.7 it is plenty fast enough.

example of jQueryUI 1.7 ~ 17.htm

example of jQueryUI 1.8 ~ 18.htm

note: the examples show the difference the most in FireFox and IE, Chrome seems ok

Both pages use the latest jqGrid 3.8 with all options selected.

loading jQuery and jQueryUI from the google CDN

<base href="http://ajax.googleapis.com/" />
<link href="/ajax/libs/jqueryui/1.8/themes/start/jquery-ui.css" type="text/css"  />
<script src="/ajax/libs/jquery/1.4/jquery.min.js" type="text/javascript"></script>
<script src="/ajax/libs/jqueryui/1.8/jquery-ui.min.js" type="text/javascript"></script>

loading jqGrid JS / CSS from my server

<link type="text/css" href="http://mymx.biz/jqGrid/ui.jqgrid.css" />
<script src="http://mymx.biz/jqGrid/grid.locale-en.js" type="text/javascript"></script>
<script src="http://mymx.biz/jqGrid/jquery.jqGrid.min.js" type="text/javascript"></script>

and my large local dataset

<script src="http://mymx.biz/jqGrid/getGridData.js?v=1" type="text/javascript"></script>

example row from dataset

var gridData = [
{id:"1",aa:"aa1",bb:"bb1",cc:"cc1",dd:"dd1",ee:"ee1", ff:"ff1",
  gg:"gg1", hh:"hh1", ii:"ii1", jj:"jj1", kk:"kk1", ll:"ll1", mm:"mm1", nn:"nn1"},
{...}
];

My basic jqGrid setup calls

    $(function () {
      var gridData = getGridData(); // pulls from getGridData.js
      setupGrid(gridData);
    });

    function SelectRow(rowid) {
      // I will be firing AJAX calls here in the future
      console.log("rowid: " + rowid);
    }

    function setupGrid(gridData) {
      $("#testGrid").jqGrid({
        data: gridData,
        height: 'auto',
        rowNum: gridData.length,
        multiselect: true,
        datatype: 'local',
        multiboxonly: false,
        gridview: true, // not sure if this is needed since jqGrid 3.6
        onSelectRow: function (rowid) { SelectRow(rowid); },
        colNames: ['id', 'aa', 'bb', 'cc', 'dd', 'ee', 'ff',
            'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn'],
        colModel: [
           { name: 'id', width: 40 },
           { name: 'aa', width: 40 },
           { name: 'bb', width: 40 },
           { name: 'cc', width: 40 },
           { name: 'dd', width: 40 },
           { name: 'ee', width: 40 },
           { name: 'ff', width: 40 },
           { name: 'gg', width: 40 },
           { name: 'hh', width: 40 },
           { name: 'ii', width: 40 },
           { name: 'jj', width: 40 },
           { name: 'kk', width: 40 },
           { name: 'll', width: 40 },
           { name: 'mm', width: 40 },
           { name: 'nn', width: 40 }
        ],
       caption: "Test Grid"
      });
    }

If anyone has some insight why the grid is so slow with jQueryUI 1.8 vs jQueryUI 1.7 would be much appreciated.

Bobby Borszich
  • 11,639
  • 9
  • 37
  • 35
  • On my Windows 7 computer both your examples 17.htm and 18.htm work in IE8, FF 3.6.10, Chrome 6.0.472.63 quickly and I can not see any distinguishes. I recommend you only include `` in the `` of the pages. – Oleg Oct 07 '10 at 16:00
  • I added the tag to the head on both pages. Where I am seeing the delay is when you click several check boxes. The 1.8 version has a lot of lag. The rendering is fine. – Bobby Borszich Oct 07 '10 at 16:21
  • Tried your links in FF3.6.10, and I see what you mean: performance when clicking various rows/checkboxes is FAR slower in the 1.8 version. – mikemanne Oct 07 '10 at 19:16
  • @mikemanne thank you for verifying, was starting to think I was going crazy ;) – Bobby Borszich Oct 07 '10 at 20:03
  • I've decided to move to a different grid plugin, and I must say - SlickGrid works well, has many features(maybe not as many as jqgrid) and most importantly - it's really fast. mleibman.github.com/SlickGrid/examples/example4-model.html – Bob Jan 05 '11 at 16:55

2 Answers2

5

"Nice" to see someone with the same problem.

I opened your example and clicking on rows or checkbox performs badly with UI 1.8.

We (php project, data locally stored in a JSON-variable, locally processed (sorting, filtering), no paging, up to 1000 records at once) were faced with the same problem and did not find a solution yet. UI 1.7 performs nice in any browser, but with the change to 1.8 we noticed some heavy performance issues with only firefox (3.6, no lower version tested). IE6, our other supported browser works fine (at least this time :-)

I tried to find out the root of this problem and used firebug to profile the runtime of different functions called after the click. I know there is a different event handling by jquery for different browsers (normalization), but I do not knwow if this has any impact.

The result can be be found here: profile.png

Maybe you see anything noticeable in this list.

As we also did not find any solution to this, we downgraded to UI 1.7.3 (which comes up with other but minor problems).

Kai

edit: Did you report this problem in the jqGrid forum? Most problems will be at least approached.

edit2: Ok, after some further investigations and some research I found a workaround. As described here (http://www.trirand.com/blog/?page_id=393/bugs/compatibility-bug-with-jquery-ui-1-8-4/), the problem can be (temporarily) solved by removing the following line from the UI's css:

.ui-widget :active { outline: none; }

I can confirm that there's no performance issue anymore after removing this line. As this rule has no effect to our style, the workaround becomes a fix for us... :-)

Koedlt
  • 4,286
  • 8
  • 15
  • 33
Kai
  • 51
  • 3
  • I will try your fix when I get a chance and mark it accordingly, the first commenter on this Question is one of the main guys who contributes to jqGrid Oleg, he didn't see it. Thanks for all your info! – Bobby Borszich Nov 17 '10 at 20:19
  • Hey Kai, I tried the fix and it doesn't seem to work on my sample page. I posted it at http://mymx.biz/jqGrid/18_mod.htm. But I marked the answer as answered because you clearly invested the time and got some good results. Thanks again. – Bobby Borszich Nov 18 '10 at 00:34
  • 1
    @Bobby Borszich: I am trying also to solve the problem. Till now wthout any success and so don't wrote anything and only voting up you question. As I read in the forum about http://www.trirand.com/blog/?page_id=393/bugs/compatibility-bug-with-jquery-ui-1-8-4/ I thought immediately about your question, but find also out that your problem will be not solved with removing of the line `.ui-widget :active { outline: none; }`. I have not yet any good results. One wrote about me, so I want only answer, that I know the problem. I'll try next experiments at morning and write about my results. – Oleg Nov 18 '10 at 00:53
  • I voting the answer of Kai, but I ask you Bobby to hold better the problem as "unsolved" till it will be **really** solved. Many people can suppose that `.ui-widget :active { outline: none; }` solve your problem, which is wrong. Are you agree? – Oleg Nov 18 '10 at 00:57
  • @Bobby Borszich: sorry I repeat one more the test and I can conform, that **removing** the line `.ui-widget :active { outline: none; }` do solve the problem. The error in my first experiment was the same as you done on the page http://mymx.biz/jqGrid/18_mod.htm you add the line `.ui-widget :active { outline: none; }` instead of removing it. You should download the original version of `jquery-ui.css`, save it on you web site and **remove the line `.ui-widget :active { outline: none; }`. I am searching a better way to remove the line without having a copy of `jquery-ui.css`. – Oleg Nov 18 '10 at 14:21
  • @Bobby Borszich: You can see the demos http://www.ok-soft-gmbh.com/jqGrid/18.htm which performance is OK in the Firefox and http://www.ok-soft-gmbh.com/jqGrid/18slow.htm which has the original jQuery UI 1.8.6 CSS and which is slow in Firefox. Till now I can not found an elegant way to remove `.ui-widget :active { outline: none; }` without having a copy of jQuery UI 1.8.6 CSS. – Oleg Nov 18 '10 at 15:08
  • @Bobby Borszich: I posted additionally http://www.trirand.com/blog/?page_id=393/bugs/compatibility-bug-with-jquery-ui-1-8-4/#p20893 to be sure that the most jqGrid user know the problem. – Oleg Nov 18 '10 at 15:33
  • I've decided to move to a different grid plugin, and I must say - SlickGrid works well, has many features(maybe not as many as jqgrid) and most importantly - it's really fast. http://mleibman.github.com/SlickGrid/examples/example4-model.html – Bob Jan 05 '11 at 16:55
1

These are general observations I've made with regard to JQGrid and IE >= 7. I've seen you example pages and many of these won't affect your specific situation.

  • IE doesn't handle large javascript well - keep your javascript small and it will load jqgrid faster.
  • Don't pass html elements when loading the grid, building them after the load improves initial load speed.
  • If you can - Use paging, this will improve load speed and interactive states.
  • You can load you whole grid data at once and still include paging - no need to call the server multiple times. This will slow initial load, but improve paging speeds.
  • If you can, add this :<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> to the head of your html. It will run IE 8 in IE 7 mode, which I find works faster with JQGrid.
  • Event propagation in jquery, so adding an event listener to a parent with children will also activate that event on the children. When interacting with other DOM object, keep this in mind. Jquery .hover prevents propagation.
  • This is an important one - :hover in IE is slow and really really slow in IE 8!
  • Jquery theme roller - The Interaction states section uses :hover on a tags and when hovering inserts a background image, which when removed improves performance a lot I find. So for exmaple background: #5d5f69 url(/content/images/ui-bg_flat_75_5d5f69_40x100.png) 50% 50% repeat-x; should be background: #5d5f69; This improves interactive states.

Let me know you findings - I'm still looking for ways to improve my grid speed too.

Bob
  • 3,074
  • 11
  • 43
  • 62