jqGrid过滤器行与网格列不同步

时间:2012-02-13 10:32:39

标签: jquery-plugins jqgrid

请看我的jsFiddle张贴:

http://jsfiddle.net/chugh97/w3Kzt/1/

我有一个固定宽度的jqGrid,启用了滚动和shrinktofit:false。现在,当我通过jqGrid过滤器文本框中的第4个字段进行选项卡时,过滤器文本框与jqGrid列无关。如何解决这个问题?

1 个答案:

答案 0 :(得分:5)

jqGrid对键盘导航的支持非常有限。我同意你描述的问题存在于jqGrid的当前(v.4.3.1)实现中。所以我可以提出+1问题。

要解决此问题,我建议以下

$('#grid').closest('.ui-jqgrid-view')
    .find('.ui-jqgrid-htable .ui-search-toolbar .ui-th-column')
    .find('input, select')
    .focus(function (e) {
        var $header = $(e.target).closest('.ui-jqgrid-hdiv'),
            $body = $header.siblings('.ui-jqgrid-bdiv');

        setTimeout(function () {
            // we syncronize the scroll in the separate thread
            // to be sure that the new scrolling value
            // already set in the grid header
            $body[0].scrollLeft =  $header[0].scrollLeft;
        }, 0);
    });

例如,Google Chrome网络浏览器需要使用setTimeout

请参阅演示here