View Full Version : ToolTip only when it need

16 Mar 2009, 1:48 AM
Hi everybody!
Sorry for my English.
Please, give me hint.
This code show tooltip every time mouse over:

public class IncidentCauseToolTipCellRenderer
implements GridCellRenderer<IncidentModel> {

private static IncidentCauseToolTipCellRenderer instance;

public String render( IncidentModel model, String property, ColumnData config,
int rowIndex, int colIndex, ListStore<IncidentModel> store ) {
// get incident status
IncidentModel incidentModel = store.getAt( rowIndex );
String incidentDescription = incidentModel.get( IncidentModel.CAUSE );
String tooltip = incidentDescription;

String html = "<span qtip='" + tooltip + "'>" + incidentDescription + "</span>";

return html;

But I need show tooltip ONLY when text width don't suite in field.
Thanks in advance.

9 Nov 2009, 4:12 AM
If someone has any suggestions on how to implement this, please post.

9 Nov 2009, 6:46 AM
maybe this idea helps you a little bit: TextMetrics

10 Nov 2009, 1:57 PM
it took me awhile to figure that code out!

11 Nov 2009, 12:50 AM
You should listen to grid's body mousemove event, then get the cell at which mouse pointer is now, then check if the cell is scrollable using Ext.fly(cell).isScrollable(), if it's scrollable then it's overflown and needs a tooltip, then you should show tooltip programmaticaly.

11 Nov 2009, 2:40 AM
if someone find a working solution - pls post a sample code :-)

11 Nov 2009, 6:24 PM
thanks for the directions guys.