Grid data isn't align with Grid header when tabbing through header columns

▼魔方 西西 提交于 2019-12-25 08:21:03

问题


when I tab through my kendo-ui grid in the header cells, I face the following issue: only the header columns are scrolled and not the content columns. See: grid with wrong aligned columns.

To reproduce this issue I created a DOJO, see: http://dojo.telerik.com/OFORe/2 .

Any ideas, how to get the content scroll with the header while tabbing? Btw when I use the horizontal scrollbar and scroll manually to the right, the columns are aligned correctly.

Thanks, bizlina


回答1:


the problem is, that kendo divides the kendo-grid into two separate tables once scrolling is enabled, as described in the kendo documentation:

When scrolling is enabled, the Grid renders two tables - one for the header area and one for the scrollable data area. (http://docs.telerik.com/kendo-ui/controls/data-management/grid/appearance#scrolling)

To achieve the two separate tables scrolling synchronously horizontally I implemented this event handler for my grid (also see the updated DOJO: http://dojo.telerik.com/OFORe/3):

 $("#grid .k-grid-header-wrap").on('scroll', function () {
        $("#grid .k-grid-content").scrollLeft($("#grid .k-grid-header-wrap").scrollLeft());
 });

With this hack the content is scrolled accordingly the header. Currently the scroll event is also called when you use the scrollbar on the bottom of the grid. To avoid that I wrapped the event in a keydown event which is registered on the input fields in the header of the grid. With a check for the correct keyCode the registration is only performed when the tab key is pressed.

P. S. to execute the scroll event only once, deregister it before using the above code.



来源:https://stackoverflow.com/questions/42513661/grid-data-isnt-align-with-grid-header-when-tabbing-through-header-columns

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!