cancel
Showing results for 
Search instead for 
Did you mean: 

TextView - show tooltip when text is blank

former_member182374
Active Contributor
0 Kudos

Hello Experts,

I'm using sap.ui.commons.TextView is my code.

I've noticed that when text is blank the tooltip is now shown.

var myTextView = new sap.ui.commons.TextView({
  text : "",
tooltip : "Tooltip" })

I tried to change the text to ' ', \0020, \t etc but text is still blank (I guess there is a function that clears white spaces)

So how can show tooltip when text is blank?

The TextView is a part of a table column so I don't want to use DOM manipulation in order to set the tooltip.

SAPUI5 version is 1.28.7.

Regards,

Omri

junwu
Active Contributor
0 Kudos

didn't get u.

show tooltip only when text is blank?

Accepted Solutions (1)

Accepted Solutions (1)

saivellanki
Active Contributor
0 Kudos

Hi Omri,

I tried to check what you're trying to do. Let me just confirm few things:

1. You're using sap.ui.commons.TextView basically just to display the text, which is similar to sap.m.Text from 'm' library.

2. TextView control is used in one of the column as a template having table as parent control. I am assuming that you're using sap.ui.table.Table control.

If above points are correct, then let's get into the issue - you say when the value is empty then tool-tip is not seen.

Yes, you will not be able to see the tool-tip when the value is not filled. As you predicted, there might be a condition if value is empty - do not show the tool tip.

(or) the easier way that I see this issue might have also caused due to height of textview control. When the value is not set, then the text view height is limited to 0px.

Here is a snap:

In order to get rid of the above problem, you might need to set the height of textview using CSS. Generally, the cell size is of '18px', you can set the same height to text view and check. It should work. I know this is not the usual way, but I see this is simple. Let me know your thoughts.

Here is a sample and snippet:

Sample: Table - JS Bin

Snippet:

e

Regards,

Answers (3)

Answers (3)

former_member182374
Active Contributor
0 Kudos

Jun - Sai explained my scenario (-:

Silvia - I know that the commons library is deprecated but I'm using multiple SAPUI5 versions and this project uses the old library.

Sai - I ended up using FormattedTextView which allows me to put which is not shown to the user and it solves the problem but your solution is better (-:

Regards,
Omri

former_member182862
Active Contributor
0 Kudos

maybe you can extend the control like this

http://jsbin.com/mikuquh/edit?html,js,output

0 Kudos

first of all... textview is deprecated since 1.38

So if you want to be on the save side after your library will be upgraded in the future (that can maybe happen 😉 ) use sap.m.TextArea

What is your usecase if the textview is part of a column and you want to display a tooltip?

If you want to support the enduser by adding content in the textarea use sap.m.TextArea and fill the property "placeholder"

If you want to use a tooltip instead to give information only if the textarea is not filled ... than you need to develop it as following.

pseudocode

textarea when liveChange (that is an event) call a function which check if content is empty if yes set tooltip if no remove tooltip

Hope that helps and is what you are looking for. If the use case is different please let me know.