0

I'm having trouble with editable jqGrid's behavior when jqGrid becomes long. Clicking on non-editable cells and submitting edited cells brings the user to the top of the grid. Randomly clicking around would produce tons of unpredictable results. The element that gets focused is set to "top:-1000000px". What would be a good resoultion for this? Is there a way to override the focus event on this element?

<script type="text/javascript">
function populateTable(table) {
    for(i = 0; i < 1000; i++) {
        table.addRowData(i, {key:'Lorem', value:'Ipsum'});
    }
}

$(document).ready(function() {
    $("#grid").jqGrid({
        datatype : "local",
        colNames : ["Key", "Value"],
        colModel: [
         {name:'key', index:'lever', width:500, editable: true},
         {name:'value', index:'defaultcpm', width: 100, editable: true},
        ],
        height: 'auto',
        cellEdit: true,
        cellSubmit: 'clientArray'
    });
    populateTable($("#grid"));
});
</script>
</head>
<body>
<table id="grid"></table>
</html>

Edit: I suppose I was not specific enough. I do not want focus change after edits. The following code fixes it, but has side effects if any non-grid HTMLDivElement receives a focus event.

HTMLDivElement.prototype.focus = function() {}
4

1 回答 1

1

如果要设置焦点,colModel 中的单元格应该是可编辑的。也尝试粘贴这个

$("#grid").jqGrid('editCell', 1, 1, true);在你的代码中。

它将焦点放在第一行第一列

于 2012-09-18T09:05:27.873 回答