Skip to Content

TextView - show tooltip when text is blank

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.



Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • Best Answer
    Nov 03, 2016 at 03:59 AM

    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




    1.jpg (257.1 kB)
    capture1.gif (79.3 kB)
    Add comment
    10|10000 characters needed characters exceeded

  • Nov 02, 2016 at 11:02 PM

    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.


    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 03, 2016 at 06:32 AM

    maybe you can extend the control like this,js,output

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 03, 2016 at 06:38 AM

    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 (-:


    Add comment
    10|10000 characters needed characters exceeded