PDA

View Full Version : How to add a tip to a cell?



yAdEs
18 Feb 2012, 12:34 AM
I wanna add tips to cells in a grid, but I can't find "mouseover" event for a cell.
In API, there are only panels,buttons and containers have such event, and they can add tips.
But cell and column doesn't. Is that mean I can't add a tip for cells and columns in a grid?

skirtle
18 Feb 2012, 8:31 AM
You can add quicktips easily enough using a custom column renderer. Something like this:


renderer: function(value, metaData) {
metaData.tdAttr = 'data-qtip="My Tooltip"';
}

mashiki
18 Feb 2012, 3:45 PM
API document shows how to do it.
http://docs.sencha.com/ext-js/4-0/#!/api/Ext.tip.ToolTip

But, renderer is more easy!
http://jsfiddle.net/mashiki/g9tQq/1/

skirtle
18 Feb 2012, 4:55 PM
Both techniques have their merits, it depends what you want to do. The renderer approach is slightly less flexible but most of the time it does the job. In some cases it can get a bit untidy sprinkling renderer functions on all the columns and then the approach shown in the docs is arguably neater.

The way it is presented in the docs only allows tooltips to vary by row. If you wanted them to vary by cell it'd need some extra work.

yAdEs
18 Feb 2012, 10:00 PM
You can add quicktips easily enough using a custom column renderer. Something like this:


renderer: function(value, metaData) {
metaData.tdAttr = 'data-qtip="My Tooltip"';
}

woo, great

yAdEs
18 Feb 2012, 10:02 PM
API document shows how to do it.
http://docs.sencha.com/ext-js/4-0/#!/api/Ext.tip.ToolTip (http://docs.sencha.com/ext-js/4-0/#%21/api/Ext.tip.ToolTip)

But, renderer is more easy!
http://jsfiddle.net/mashiki/g9tQq/1/

You helps a lot ! Thanks!

yAdEs
18 Feb 2012, 10:07 PM
Both techniques have their merits, it depends what you want to do. The renderer approach is slightly less flexible but most of the time it does the job. In some cases it can get a bit untidy sprinkling renderer functions on all the columns and then the approach shown in the docs is arguably neater.

The way it is presented in the docs only allows tooltips to vary by row. If you wanted them to vary by cell it'd need some extra work.


Right, like I can't put infomation for the cell in Tip if I can't target it by render function.

yAdEs
18 Feb 2012, 10:10 PM
I want to put some information about the cell in the Tip,like it was edited by who and when, So the render function can't help too much.:-?

yAdEs
18 Feb 2012, 10:14 PM
And my Grid is huge, render function waste too much,right?

mashiki
19 Feb 2012, 4:35 PM
skirtle,

I read only the word "Grid" and of "Tooltip" of a document.
Doc code is for entire row, not for a cell.

Thank you for your explanation.
I found each difference, strong points, and demerits.