【问题标题】:Dynamically add tooltips to kendo grid rows of a column将工具提示动态添加到列的剑道网格行
【发布时间】:2012-09-20 07:50:57
【问题描述】:

我有一列显示一些注释。由于注释很大,我已经缩短了控制器本身的注释并将其发送到我的 aspx 页面。我想要实现的是,我想在鼠标悬停在网格行上(或者如果可能的话正好在单元格上)以工具提示的形式显示完整的注释。有什么办法可以做到这一点?任何帮助将不胜感激。提前致谢。

【问题讨论】:

  • 为错误的标题道歉。标题必须是这样的“为剑道网格中的动态内容添加工具提示”。
  • 你为什么不接受你的解决方案?

标签: kendo-ui kendo-grid kendo-tooltip


【解决方案1】:

发布答案,因为它可能对任何人都有帮助。

这样做后我得到了它的工作......

columns.Bound(p => p.partialNotes).Title("Description").HeaderHtmlAttributes(new { style = "text-align:center" }).HtmlAttributes(new { style = "text-align:left" }).Width("8%").HtmlAttributes(new { title =  "#= completeNotes #" });

我刚刚添加了 HtmlAttributes(new { title = "#= completeNotes #" })

所以现在当我将鼠标放在 Description 列数据上时,我会得到完整的 Notes 作为工具提示。

【讨论】:

    【解决方案2】:

    也可以使用第 3 方小部件。我已将qtip 提示添加到这样的列标题

    KendoUI 网格列数组项

    {
        field:"property",
        headerTemplate:kendo.template($("#h_Entity_property").html())
    },
    

    标题模板

    <link rel="stylesheet" type="text/css" href="lib/Craga89-qTip2-bfcc9ef/dist/jquery.qtip.min.css"/>
    <link rel="stylesheet" type="text/css" href="lib/Craga89-qTip2-bfcc9ef/util/qtip.util.css"/>
    <script type="text/javascript" src="lib/Craga89-qTip2-bfcc9ef/dist/jquery.qtip.min.js"></script>
    <script type="text/javascript" src="lib/Craga89-qTip2-bfcc9ef/util/Dialogues.js"></script>
    <script type="text/javascript" src="lib/Craga89-qTip2-bfcc9ef/util/Qtip2Util.js"></script>
    
    <script type="text/x-kendo-template" id="h_Entity_property">
        Property
        <img onclick="Qtip.local(this, 'i_Entity_property')" src="img/info.gif"/>
        <div id="i_Entity_property" style="display:none;">
            Elaborate a bit...
        </div>
    </script>
    

    工具提示生成器

    var Qtip = {
        local:function (element, contentId) {
            $(element).qtip($.extend({}, qTipSharedOptions, {
                    content:{
                        text:$('#' + contentId).html(),
                        title:{
                            text:' ',
                            button:true
                        }
                    }
                }
            ));
        },
        ...
    };
    
    var qTipSharedOptions = {
        position:{
            at:'top right', // Position the tooltip above the link
            my:'bottom left',
            viewport:$(window), // Keep the tooltip on-screen at all times
            effect:false // Disable positioning animation
        },
        style:{
            classes:'ui-tooltip-tipsy ui-tooltip-shadow'
        },
        show:{
            ready:true,
            event:false,
            solo:true // Only show one tooltip at a time
        },
        hide:false
    };
    

    【讨论】:

      【解决方案3】:

      你可以这样做:

      $("#Kendo-grid-div-id").kendoTooltip({
          filter: "td:nth-child(2),td:nth-child(3)", //comma separated multiple columns
          position: "bottom",     //possible values: bottom,top,left,right,center
          content: function(e){
            var content = e.target.html();
            return content;
          }
        }).data("kendoTooltip");
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-01-16
        相关资源
        最近更新 更多