Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically add tooltips to kendo grid rows of a column

I have a column with some notes displaying in the rows. Since the notes are huge, I have cut short the notes in the controller itself and sent that to my aspx page. What I want to achieve is, I want to display the complete notes in the form of a tool tip on mouse over of the grid row ( or if possible exactly on cell ). Is there any way to achieve this? Any help would be highly appreciated. Thanks in Advance.

like image 815
Hari Avatar asked Sep 20 '12 07:09

Hari


2 Answers

Posting the answer as it might help anyone.

I got that working after doing this...

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 #" });

I have just added HtmlAttributes(new { title = "#= completeNotes #" })

So now when I place the mouse over the Description column data , I get the complete Notes as a tool tip.

like image 173
Hari Avatar answered Oct 20 '22 04:10

Hari


Using a 3rd party widget is also a possibility. I've added qtip tips to column headers like this enter image description here

KendoUI grid column array item

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

The header template

<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>

Tooltip generator

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
};
like image 3
Kristo Aun Avatar answered Oct 20 '22 04:10

Kristo Aun