【问题标题】:Apply Jquery tooltip on jqgrid custom formatted cell在 jqgrid 自定义格式化单元格上应用 Jquery 工具提示
【发布时间】:2014-01-08 17:44:29
【问题描述】:

我正在拼命地尝试在一些 jqgrid 单元格上实现 jquery 工具提示。我将单元格格式化为具有自己的标题,如下所示:

<td role="gridcell" style="" title="Toto, Tata" aria-describedby="MyTaskUserView_TaxpayerName">
    <span class="fullCellSpan customTooltip" title="123456" originalvalue="Toto Tata">Toto Tata</span>
</td> 

我试图在包含标题的跨度上调用工具提示:

  $("td span.customTooltip").tooltip();

我不明白为什么它不起作用。

如果我这样称呼它

$(document).tooltip();

它会起作用,但它会在每个具有我不想要的标题元素的元素上应用工具提示。

好像它没有识别出我不理解的 html 路径。

提前感谢您的帮助

【问题讨论】:

    标签: jquery jqgrid tooltip


    【解决方案1】:

    我发现了这个错误,当我调用工具提示时,网格还没有完成加载。 由于我使用的是 JqGrid ASP.NET MVC 许可证,因此我使用模型的 ClientSideEvents.GridInitialized 属性来了解何时加载网格,然后触发工具提示。

    MyGrid.ClientSideEvents.GridInitialized = "initGrid";
    
    function initGrid() {
    $("td span.fullCellSpan").tooltip({
        hide: {
            effect: "fade",
            duration: 500
        },
        position: {
            my: "left center",
            at: "right top",
            collison: "flip"
        },
        show: {
            effect: "fade",
            duration: 800
        }
    });
    }
    

    希望这可以帮助其他用户。

    【讨论】:

      【解决方案2】:

      较新的方法是使用 cellattr 函数,在 asp.net 库中是:

      <Formatter>
          <trirand:CustomFormatter SetAttributesFunction="clientSideFunctionName" />
      </Formatter>
      

      更多详情可以在这里找到:https://stackoverflow.com/a/5281391/356218https://stackoverflow.com/a/12215880/356218

      JS 看起来像这样:

      function clientSideFunctionName(rowId, tv, rawObject, cm, rdata) {
          //conditional formatting
           if (Number(rawObject[colMap.missingBooks]) > 0) {
               return ' style="background-color:#FFCCCC" title="tooltips are cool!"';
           } else {
               return '';
           }
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-10-26
        • 1970-01-01
        • 2016-09-12
        相关资源
        最近更新 更多