【问题标题】:why the scrollbar override the toolbar?为什么滚动条会覆盖工具栏?
【发布时间】:2017-02-25 06:05:27
【问题描述】:

我已经使用scrollbars top and bottom 中的代码创建了一个类似于带有顶部和底部滚动条的链接上的网格。但是当我使用

toolbar: [true, "top"],

$('<div><input type="button" value="Send" /></div>').appendTo("#t_grid");

带有添加按钮的工具栏不会显示,而是仅在顶部显示滚动条。滚动条似乎覆盖了工具栏。

我有以下问题:

如何将我的工具栏与按钮一起包含在顶部滚动条中? (在此工具栏必须位于顶部滚动条的上方)

【问题讨论】:

    标签: jquery jqgrid free-jqgrid


    【解决方案1】:

    The old demo,我为the answer 创建的,使用顶部工具栏进行滚动。因此,顶部工具栏的所有内容(在您的情况下为“发送”按钮)将被滚动。

    可以通过在顶部工具栏的 div 之后插入 一个单独的 div 来轻松解决问题。相应的代码将是

    var $bdiv = $grid.closest(".ui-jqgrid-bdiv"),
        $topToolbar = $("#t_" + $grid[0].id),
        $scrollBar = $('<div class="ui-state-default" id="tscroll_' + $grid[0].id +
            '" style="overflow-x:scroll;overflow-y:hidden;"><div style="height:1px;width:' +
            $grid.width() + 'px;"></div></div>');
    
    // insert the custom content in the  top toolbar
    $('<div><input type="button" value="Send" /></div>').appendTo($topToolbar);
    $topToolbar.css("height", "auto");
    
    // append the new div with the scroll bar on top of the grid
    $topToolbar.after($scrollBar[0]);
    
    // synchronize the scroll position of $scrollBar and $bdiv
    $scrollBar.scroll(function () {
        // synchronize the srollbar of the grid
        $bdiv.scrollLeft($(this).scrollLeft());
    });
    $bdiv.scroll(function () {
        // synchronize the srollbar of the toppbar
        $scrollBar.scrollLeft($(this).scrollLeft());
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-07
      • 2015-11-29
      • 1970-01-01
      • 1970-01-01
      • 2017-04-07
      • 2022-08-16
      • 1970-01-01
      相关资源
      最近更新 更多