[ 7 posts ]

Daniel Jonson

  • Username: denne
  • Joined: Wed Jun 16, 2010 5:09 am
  • Posts: 3
  • Offline
  • Profile

Adding tooltip text to header in datatable?

Post Posted: Wed Jun 16, 2010 5:19 am
+0-
I have searched all over internet and tried to find a way to add a tooltip to the datatable headers.
I want to replace the standard "Click to sort..:" for some of the header-fields in my datatable but must be stupid because I cant find a hint anywhere on how to do this. I suspect that it could be quite simple to do but somehow I cant find any solution after 4 hours of googling and trying.

Could someone please give a YUI-neewb some help... please..

Satyam

YUI Contributor

  • Username: Satyam
  • Joined: Tue Dec 09, 2008 12:34 am
  • Posts: 2016
  • Location: Sitges, Spain
  • GitHub: Satyam
  • Gists: Satyam
  • IRC: DevaSatyam
  • YUI Developer
  • Offline
  • Profile

Re: Adding tooltip text to header in datatable?

Post Posted: Wed Jun 16, 2010 6:00 am
+0-
Those two text will be automatically applied to the headers of sortable columns and they are taken from the MSG_SORTASC and MSG_SORTDESC configuration attributes

http://developer.yahoo.com/yui/docs/YAH ... SG_SORTASC

Whatever text you store in those configuration attributes will be applied to sortable columns only. There is no easy way to provide tooltips of your own besides changing those two strings. I hope changing those texts is all you wanted because doing anything else would be quite hard, specially since you would be constantly fighting DataTable's own built-in tooltips.

Daniel Jonson

  • Username: denne
  • Joined: Wed Jun 16, 2010 5:09 am
  • Posts: 3
  • Offline
  • Profile

Re: Adding tooltip text to header in datatable?

Post Posted: Thu Jun 17, 2010 12:23 am
+0-
Thanx for the answer Satyam!
I try to provide tooltips for each column in the header so manipulating the constants would change for all the columns and thats not working for me.

I will try another approach, with an Information icon in the header with the label, with a tooltip connected to the icon and see if that works better.

I think one problem with that approach is that the standard tooltip is always shown when the mouse pointer is over the header which would display both my tooltip and the standard tooltip at the same time.

Daniel Jonson

  • Username: denne
  • Joined: Wed Jun 16, 2010 5:09 am
  • Posts: 3
  • Offline
  • Profile

Re: Adding tooltip text to header in datatable?

Post Posted: Fri Jun 18, 2010 3:00 am
+0-
I set both MSG_SORTASC and MSG_SORTDESC to empty strings, which disabled all sorting tooltips completely.

Then I used the example on http://www.satyam.com.ar/yui/#tooltips and changed it to listen to theadLabelMouseoutEvent and theadLabelMouseoverEvent to show and hide the tooltip in the headers. It seems to work very well.

sjJNL

  • Username: sjJNL
  • Joined: Thu Jul 08, 2010 6:58 am
  • Posts: 42
  • GitHub: sjJNL
  • Gists: sjJNL
  • Offline
  • Profile

Re: Adding tooltip text to header in datatable?

Post Posted: Wed Mar 21, 2012 12:19 pm
+0-
Could you post an example for this?

Or a short code snippet of how this was done?

Vimal Maheedharan

  • Username: vimalmahi
  • Joined: Mon May 21, 2012 5:37 am
  • Posts: 1
  • Offline
  • Profile

Re: Adding tooltip text to header in datatable?

Post Posted: Mon May 21, 2012 5:45 am
+0-
Satyam/Dany,

Rather than modifying the configuration values can't we do like this? Any issues?

//Just below myColumnDefs

var toolTipText = "Text on hover"
YAHOO.util.Event.addListener("headerCell_ID", "mouseover", showToolTip);

function showToolTip(ev){
var yDom = YAHOO.util.Dom;//get the DOM Util Object
var c = yDom.getChildren(yDom.getChildren(ev.target)[0]);// here we will get the <a> DOM
yDom.setAttribute(c[0], "title", bcToolTipText); //Sets <a title="Text on hover"> for the header
}

Satyam

YUI Contributor

  • Username: Satyam
  • Joined: Tue Dec 09, 2008 12:34 am
  • Posts: 2016
  • Location: Sitges, Spain
  • GitHub: Satyam
  • Gists: Satyam
  • IRC: DevaSatyam
  • YUI Developer
  • Offline
  • Profile

Re: Adding tooltip text to header in datatable?

Post Posted: Mon May 21, 2012 6:52 am
+0-
That is what the ToolTip utility, part of the Container family, does for you. If you want to show more fancy tooltips, that is the best choice.

Regarding your showToolTip method, it is not good to use getChildren or, in general, assume a particular structure on the HTML the DataTable produces. Now that it is not longer a maintained product it is not bound to change but, in general, you should not assume the markup will remain stable. Instead, use the many getXxxxEl() methods which provide you with getters for most HTML. For example, the ScrollDataTable actually uses two separate HTML tables, if you play with the DOM, you might end up using the wrong one. Let DataTable tell you which one is using.
  [ 7 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum