3

The grid (v4.3.1) selects the correct values in the drop down when going into edit mode.

However, there seem to be an issue with IE 7 and IE 8, which automatically select the first item, along with the other values that also should get selected.

Have anyone stumbled upon this with IE7/8?

While studying the source for jqgrid I also saw a commented line that actually would fix this issue. It was commented in this changeset and fixed another issue, as Oleg commented. Haven't yet found out what that issue was though.

Simon
  • 78
  • 7
  • I tested [the demo](http://www.ok-soft-gmbh.com/jqGrid/Chhaya2.htm) from [the answer](http://stackoverflow.com/a/6960946/315935) where I just used the last version of jqGrid. In my tests all worked correctly. You should probably post the demo or the link to the demo where `jquery.jqGrid.src.js` are used and where one can reproduce the described problem. – Oleg Mar 13 '12 at 12:31
  • I do can reproduce the problem which you described on [the demo](http://www.ok-soft-gmbh.com/jqGrid/OptGroupMultiple1.htm) from [the answer](http://stackoverflow.com/a/6505546/315935). I will examine toe problem more and will post you the results. – Oleg Mar 13 '12 at 12:45
  • 1
    "Good" :) had already started scratching my soon to be bold head. I compared your demo code with mine. What differed was that you also had `value: ''`. I tried this out of curiosity and it seems to work. – Simon Mar 13 '12 at 13:02

1 Answers1

3

I examined the described problem and can confirm, that it's a bug in jqGrid. So +1 for you in any way.

The line

//if(i===0) { this.selected = ""; }

was commented after the fix which you referenced was made based on the problem with single selected selects. See the post. So I can suggest two ways to fix the problem:

1) replace the above comment to the following lines

// fix IE8/IE7 problem with selecting of the first item on multiple=true
if (i === 0 && elem.multiple) { this.selected = false; }

2) add instead of that after the $("option",elem).each(function(i){...}) the lines

// fix IE8/IE7 problem with selecting of the first item on multiple=true
var $first = $("option:first",elem);
if($.inArray($.trim($first.text()),ovm) < 0 && $.inArray($.trim($first.val()),ovm) < 0 ) {
    $first[0].selected = false;
}

I am not sure which bug fixing is the most safe.

The demo can be used to reproduce the bug. One can use IE9, start Developer Tools with F12, choose IE8 as the "Browser mode" and choose "IE Standards" as the "Document Mode". After all one can select item "SM000237" in the grid and verify that "Accounting free" item are selected together with "Bank Fees" instead of selecting only the "Bank Fees".

The first and the second demos both fixes the bug and use the described above fixes.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Hopefully it'll be fixed in the next version so that we don't reintroduced the problem. – Simon Mar 13 '12 at 14:05
  • @Simon: I posted [my suggestions](http://www.trirand.com/blog/?page_id=393/bugs/bug-in-ie8ie7-with-selecting-of-the-first-item-in-selects-in-case-of-multipletrue/#p26121) just now to trirand. I hope the problem will be fixed soon in the main code of jqGrid. – Oleg Mar 13 '12 at 14:10