/scripts/ahub.form.attachments.js
0

TextView - show tooltip when text is blank

Nov 02, 2016 at 12:31 PM

152

avatar image

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

10 |10000 characters needed characters left characters exceeded

didn't get u.

show tooltip only when text is blank?

0
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Sai Vellanki Nov 03, 2016 at 03:59 AM
0

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,


1.jpg (257.1 kB)
capture1.gif (79.3 kB)
Share
10 |10000 characters needed characters left characters exceeded
Silvia Grabmann Nov 02, 2016 at 11:02 PM
0

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.

Share
10 |10000 characters needed characters left characters exceeded
Dennis Seah
Nov 03, 2016 at 06:32 AM
0

maybe you can extend the control like this

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

Share
10 |10000 characters needed characters left characters exceeded
Omri Cohen Nov 03, 2016 at 06:38 AM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Skip to Content