在IE7/8的编辑模式下,JqGrid多选择列表始终选择了第一个选项 [英] JqGrid multi select list always has first option selected in edit mode with IE7/8

查看:60
本文介绍了在IE7/8的编辑模式下,JqGrid多选择列表始终选择了第一个选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

进入编辑模式时,网格(v4.3.1)在下拉列表中选择正确的值.

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

但是,IE 7和IE 8似乎存在问题,它们会自动选择第一项,以及也应选择的其他值.

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.

有人用IE7/8偶然发现此问题吗?

Have anyone stumbled upon this with IE7/8?

在研究jqgrid的源代码时,我还看到一条注释行,它实际上可以解决此问题.在此更改集中对此进行了评论,并修复了另一个问题,正如Oleg所评论的那样.尚未发现那是什么问题.

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.

推荐答案

我检查了所描述的问题,并可以确认这是jqGrid中的错误.因此,您可以通过任何方式+1.

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

该行

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

修复是基于<选中的strong>单个进行选择.参见

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)将以上注释替换为以下几行

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)添加而不是在$("option",elem).each(function(i){...})行之后添加

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.

该演示可用于重现该错误.可以使用IE9,使用 F12 启动开发人员工具,选择IE8作为浏览器模式",然后选择"IE标准"作为文档模式".毕竟,所有人都可以在网格中选择项目"SM000237",并验证是否选择了免费会计"项目和银行费用",而不是仅选择银行费用".

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.

这篇关于在IE7/8的编辑模式下,JqGrid多选择列表始终选择了第一个选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆