Mlodey Mlodey - 2 months ago 6x
Javascript Question

ColumnChooser free-jqgrid is not working on IE9

After upgrade of my application from jqGrid 4.6 to free-jqgrid 4.8 the columnChooser functionality is not working. It's only on IE9. Demo is available here: (Please open it in IE9 mode).

The problem I think is in apply_perm function in jqGrid library:

apply_perm: function () {
var perm = [];
$("option", select).each(function () {
if ($(this).is("[selected]")) {
$self.jqGrid("showCol", colModel[this.value].name);
} else {
$self.jqGrid("hideCol", colModel[this.value].name);

When I changed
if ($(this).is("[selected]"))
if ($(this).is(":selected"))
it started to work.

What is the difference between


Thank you for the bug report! I like questions with the demo which can be used to reproduce the problem.

It's the bug in jqGrid 4.7 (see the line and compare it with the corresponding line of jqGrid 4.6). The best test for selected option is the usage of .is(":selected"). The corresponding implementation of jQuery uses all specifics of the implementation in different version of web browsers. The selector .is("[selected]") means that the selected attribute exist with some value. Typically the attribute selected should have the value "selected" (selected="selected"). My test using your demo shows that in case of IE9 one have selected="" value and the test .is("[selected]") returns wrong value true instead of .is(":selected") provides the correct value false.

I fixed the line in the code of free jqGrid and additionally the close selector $("option[selected]", select) to $("option", select).filter(":selected").

I posted the fix to github. Because you use in your demo the URL // then the demo will uses the modified code now. You can verify that it works correctly now in IE9.