开发者

how to allow to use case sensitive row ids in jqGrid

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

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"]}

]}


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:

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.

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.

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>

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.

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.

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.

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜