jqGrid horizontal scrollbar at top by header(jqGrid水平滚动条在顶部由标题)
问题描述
只是好奇是否有人知道将水平滚动条添加到 jqGrid 顶部的方法(例如在标题下方或上方)?我正在使用冻结列和高度:自动但是当有很多行时,用户必须向下滚动才能水平滚动网格并且看不到标题......我做了一些搜索,看起来在大多数情况下滚动条很难弄乱,但我想我会把它放在那里.
谢谢!
我觉得你的问题很有趣.我投入了一些时间并创建了 作为创建顶部滚动条的基础.此外,如果用户在 Web 浏览器中使用缩放,我还包括了固定所有 jqGrid 潜水的大小和位置的代码部分.
我的答案代码中最重要的部分包括在下面:
var $grid = $("#list");//创建带有一些冻结列的网格$grid.jqGrid({……});var $gview = $grid.closest(".ui-jqgrid-view"),$topToolbar = $gview.find(">.ui-userdata"),$bdiv = $grid.closest(".ui-jqgrid-bdiv"),重置顶部工具栏高度 = 函数 () {var 滚动条高度 = 18;//一些测试值$topToolbar.find(">div").height(scrollbarHeight);$topToolbar.css("border-top", "0").css("height", "auto");scrollbarHeight = $topToolbar.height() - scrollbarHeight;$topToolbar.find(">div").height(scrollbarHeight);$topToolbar.height(scrollbarHeight);fixPositionsOfFrozenDivs.call($grid[0]);};//在顶部工具栏中插入空 div 并设置其宽度//与网格的宽度相同$topToolbar.css({ overflowX: "scroll", overflowY: "hidden"}).append($("<div>").width($grid.width()));//设置div的高度和工具栏的高度//基于水平滚动条的高度重置顶部工具栏高度();//检测 topbar 的滚动$topToolbar.scroll(函数 () {//同步网格的滚动条$bdiv.scrollLeft($(this).scrollLeft());});//检测网格的滚动$bdiv.scroll(函数 () {//同步toppbar的srollbar$topToolbar.scrollLeft($(this).scrollLeft());});//检测页面的缩放并调整$(window).on("resize", function () {重置顶部工具栏高度();fixPositionsOfFrozenDivs.call($grid[0]);});
我从关于冻结列的使用的旧答案中获得的代码的其他部分.
Just curious if anyone knows of a way to add a horizontal scrollbar to the top of jqGrid (like just under or above the headers)? I'm using frozen columns and height:auto but when there are lots of rows, the user has to scroll down to scroll the grid horizontally and can't see the headers... I did some searching and it looks like scrollbars are hard to mess with in most cases, but I figured I would just put it out there.
Thanks!
I find your question interesting. I invested some time and created the following demo which demonstrates how your requirements could be implemented. It displays
where one can use both horizontal scrollbars on the top or on the bottom of the grid. I used the answer as the basis of creating the top scroll bar. Additionally I included the part of code which fixed the size and position of all jqGrid dives in case if the user uses zoom in the web browser.
The most important part of the code of my answer I included below:
var $grid = $("#list");
// create the grid with some frozen columns
$grid.jqGrid({
....
});
var $gview = $grid.closest(".ui-jqgrid-view"),
$topToolbar = $gview.find(">.ui-userdata"),
$bdiv = $grid.closest(".ui-jqgrid-bdiv"),
resetTopToolbarHeight = function () {
var scrollbarHeight = 18; // some test value
$topToolbar.find(">div").height(scrollbarHeight);
$topToolbar.css("border-top", "0").css("height", "auto");
scrollbarHeight = $topToolbar.height() - scrollbarHeight;
$topToolbar.find(">div").height(scrollbarHeight);
$topToolbar.height(scrollbarHeight);
fixPositionsOfFrozenDivs.call($grid[0]);
};
// insert empty div in the top toolbar and make its width
// the same as the width of the grid
$topToolbar.css({ overflowX: "scroll", overflowY: "hidden"})
.append($("<div>").width($grid.width()));
// set the height of the div and the height of toolbar
// based on the height of the horizontal scrollbar
resetTopToolbarHeight();
// detect scrolling of topbar
$topToolbar.scroll(function () {
// synchronize the srollbar of the grid
$bdiv.scrollLeft($(this).scrollLeft());
});
// detect scrolling of the grid
$bdiv.scroll(function () {
// synchronize the srollbar of the toppbar
$topToolbar.scrollLeft($(this).scrollLeft());
});
// detect zoop of the page and adjust the
$(window).on("resize", function () {
resetTopToolbarHeight();
fixPositionsOfFrozenDivs.call($grid[0]);
});
Other parts of the code I get from my old answers about the usage of frozen columns.
这篇关于jqGrid水平滚动条在顶部由标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:jqGrid水平滚动条在顶部由标题


- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- Flexslider 箭头未正确显示 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07