如何允许在jqGrid中使用区分大小写的行ID [英] how to allow to use case sensitive row ids in jqGrid

查看:90
本文介绍了如何允许在jqGrid中使用区分大小写的行ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果jqGrid行ID(作为与服务器中json数据分开的id属性传递的id属性)仅因大小写不同,则无法正确开始内联

If jqGrid row ids (passed as separate id property from json data in server) are different only by case, inline edit is not started properly:

双击第二行将第一行置于内联编辑模式. 如何使jqgrid行ID区分大小写?

double clicking in second row puts first row in inline edit mode. How to make jqgrid row ids case sensitive ?

从服务器读取的数据是:

Data read from server is:

{"total":1,"page":1,"records":2,"rows":[

{"id":"arvelduste_20seis","cell":[null,"arvelduste seis"]},
{"id":"Arvelduste_20seis","cell":[null,"Arvelduste seis"]}

]}

推荐答案

在我看来,它似乎是Internet Explorer中的错误.在官方文档对象模型HTML标准中,我可以找到以下关于jqGrid大量使用的namedItem方法的描述:

It seems for me as a bug in Internet Explorer. In the official Document Object Model HTML standard I could found the following description about the namedItem method intensively used by jqGrid:

此方法使用名称检索节点.使用[HTML 4.01]文档, 它首先搜索具有匹配id属性的Node.如果它 找不到一个,然后搜索名称匹配的节点 属性,但仅在允许使用名称的那些元素上 属性.对于[XHTML 1.0]文档,此方法仅搜索 具有匹配的id属性的节点.此方法不区分大小写 HTML文档和XHTML文档中的区分大小写.

This method retrieves a Node using a name. With [HTML 4.01] documents, it first searches for a Node with a matching id attribute. If it doesn't find one, it then searches for a Node with a matching name attribute, but only on those elements that are allowed a name attribute. With [XHTML 1.0] documents, this method only searches for Nodes with a matching id attribute. This method is case insensitive in HTML documents and case sensitive in XHTML documents.

因此namedItem方法应该在 XHTML文档中区分大小写.另一方面,您可以在演示中进行测试,该演示仅使用纯DOM而没有jQuery或jqGrid,该方法在Internet Explorer中不区分大小写.

So the namedItem method should works case sensitive in XHTML documents. On the other side like you can test in the demo, which use only pure DOM without jQuery or jqGrid, the method work case insensitive in Internet Explorer.

该示例的HTML代码如下:

The HTML code of the demo is following:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>http://stackoverflow.com/questions/7230179/how-to-allow-to-use-case-sensitive-row-ids-in-jqgrid/7236985#7236985</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
    <table id="t">
        <tbody>
            <tr id="x"><td>1</td></tr>
            <tr id="X"><td>2</td></tr>
        </tbody>
    </table>
    <script type="text/javascript">
        'use strict';
        var mytable = document.getElementById("t"),
            tr1 = mytable.rows.namedItem("x"),
            tr2 = mytable.rows.namedItem("X"),
            tr3 = document.getElementById("x"),
            tr4 = document.getElementById("X");
        alert("getElementById works " + (tr3.id === tr4.id ? "case insensitive (BUG!!!)": "case sensitive") +
              "\nnamedItem works " + (tr1.id === tr2.id ? "case insensitive (BUG!!!)": "case sensitive"));
    </script>
</body>
</html>

Internet Explorer显示namedItem("X")返回具有id ="x"的行,而不是具有id ="X"的行.在我测试过的所有其他(非Microsoft)网络浏览器中都没有相同的错误.

The Internet Explorer shows that namedItem("X") returns the row with the id="x" instead of the row having id="X". The same bug not exist in all other (non-Microsoft) web browsers where I tested it.

我不能建议您当前没有解决方法.您应该只组织程序,以免在表内部(以及与jqGrid一起使用)区分大小写的ID.

I can't suggest you currently no workaround. You should just organize you program so that you will not use case sensitive ids inside of tables (and with jqGrid).

已更新:仅需更多其他信息.

UPDATED: Just a little more additional information.

我就上述主题向Microsoft发出了正式支持请求. Microsoft确认这是Internet Explorer中的错误,但是在当前Internet Explorer版本中该错误不会得到修复,但是可能是 在IE10中已修复.解决方法:-)建议不要使用仅区分大小写的id.因此,请不要使用可以重现该错误的ID.因此,最终的结果与我之前的评论中所预期的一样.

I made an official support request to Microsoft about the described subject. Microsoft confirmed that it was a bug in Internet Explorer, but the bug will be not fixed in the current Internet Explorer versions, but it will be probably fixed in IE10. As a workaround :-) it was suggested not to use ids which distinguish only in case. So just not use the ids which can reproduce the bug. So we have at the end results as I supposed before in my previously comments.

尽管如此,因为响应确认这是一个错误,所以对我来说对Microsoft的请求是免费的(:-)).

Nevertheless, because the response confirmed that it was a bug, the request to Microsoft was for free for me (:-)).

这篇关于如何允许在jqGrid中使用区分大小写的行ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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