【问题标题】:Free-jqGrid – Button on caption click works only at centerFree-jqGrid – 标题点击按钮仅在中心有效
【发布时间】:2017-06-08 22:01:47
【问题描述】:

我有一个免费的 jqGrid,如下所示。它有一个带有+ 图标的按钮。

预期行为:鼠标悬停时加号图标的颜色变为白色,单击时会显示警告消息。

但此功能仅在鼠标指向按钮中心时才有效。如果我从浏览器的右边缘移动鼠标并到达按钮的右下角,则不会发生视觉变化——点击时什么也不会发生。但是,如果我在一个简单的动态按钮(没有网格)上执行此操作,如第二小提琴所示,它可以正常工作。

  1. 网格标题中的按钮:Fiddle 1
  2. 单独的动态按钮:Fiddle 2

如何在 free-jqgrid 中修复/解决这个问题?

注意:我使用的是 Google Chrome 版本 58。

字幕脚本

var htmlButtonElement = '<button id="btnAddProvider" type="button" class="btn btn-info toolbar-button" title="Add Provider" style="float:left;">'+
              '<span id="spanAddProvider" class="glyphicon glyphicon-plus" style="pointer-events: none;"></span>'+
          '</button>'


        function getGridCaption() {
            return "<div style='font-size:15px; font-weight:bold; display:inline; padding-left:10px;'><span class='glyphicon glyphicon-check' style='margin-right:3px;font-size:14px;'></span>" + getCurrentPractice() + " " + "</div>" +
            "<div style='float:right; padding-right:20px; padding-bottom:10px; display:inline;>" +
           "<div style='float:right;width:550px;  padding-bottom:20px;'>" +
                 "<div class='btn-group' style='float:right; padding-top:1px;'> " +
                  htmlButtonElement+
                "</div>" +
                "<input type='text' class='form-control' id='filter' placeholder='Search'  style='width:250px; height:30px; float:right; ' />" +
            " </div>" +
            "</div><div class='ui-helper-clearfix'></div>";
        }

更新

根据 Oleg 的回答修复:Fiddle 3

【问题讨论】:

    标签: jqgrid free-jqgrid


    【解决方案1】:

    在我看来,您的问题更多关于 jQuery UI CSS,您将其用作免费 jqGrid。 jQuery UI 类的大多数元素除了background-color 之外还定义了background-image。确切地说,jQuery UI 使用background 来定义background-imagebackground-color 和其他一些background-xxx CSS 属性。因此,您应该使用background: silver 而不是background-color: silver 或继续使用background-color: silver,但另外添加background-image: none。您可以另外定义:hover 规则(如.toolbar-button:hover)来定义悬停状态下按钮的CSS 属性。例如,演示https://jsfiddle.net/OlegKi/x59xx4n1/3/ 使用以下属性

    .toolbar-button {
        background-color: silver;
        background-image: none;
        color: darkblue;
    }
    .toolbar-button:hover {
        background-color: green;
        color: yellow;
    }
    

    更新:另一个演示 https://jsfiddle.net/OlegKi/x59xx4n1/5/ 使用 hidegrid: false 选项并从网格标题中删除 ui-jqgrid-caption 类。

    【讨论】:

    • 我检查了你的小提琴 - 也存在问题。当我从右下角移动鼠标时,它不会突出显示。它仅在我到达按钮中心附近时才起作用。仅当按钮位于网格上时才会出现此问题。当我制作一个独立的动态按钮时,它可以完美地工作(如第二个小提琴)。您是否能够使用 Chrome 看到这种行为?
    • @Lijo:您在插入标题栏中的元素上使用了太多 CSS 样式。您需要分析,哪一个与其他 CSS 属性有问题。无论如何,问题取决于应用于"ui-jqgrid-caption" 类的 CSS 规则,该类用于定位显示/隐藏按钮,很少使用。我建议您使用hidegrid: false 选项删除按钮,最后删除"ui-jqgrid-caption" 类。见jsfiddle.net/OlegKi/x59xx4n1/5
    • 谢谢。有用。两个请求。 1)您能否用此评论和小提琴更新/替换答案? 2)您能否详细说明为什么在添加hidegrid: false 和删除ui-jqgrid-caption 时它会修复?
    • @Lijo:我更新了答案。您可以在演示中删除 hidegrid: false 选项,该选项在标题栏中没有 ui-jqgrid-caption 类。你会看到隐藏/显示按钮的位置绝对不对。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-20
    相关资源
    最近更新 更多