88
Views
10
Comments
Solved
Long text field, showmore/showless functionality
Application Type
Reactive

Hi All,


I have large text field to which I need to provide show more/ show less functionality.

Is there any way to do this?


Thanks

Shivangi

2024-05-14 06-52-28
Srigovindh-EONE
Solution

Hi Shivangi,

click here

Option 1: Use the TextEllipsis(value,30) function to shorten the text and add the attribute in the property panel.

title =value

Option 2: Use the substr() in Expression. For example, if (length(value)>30, substr(value, 0, 30), value) and add a tooltip inside the content with "..." and a tooltip expression (Value).

longtext.oml
2024-06-19 09-49-45
edubaixo
Solution

Hi Shivangi

You can use a link or some other input type that changes a local variable that contains the state of the Show More value (ShowMoreIsActive - Boolean)

Then you can then encapsulate your text in an If expression like this:

If(ShowMoreIsActive,YourText,Substr(YourText,0,50)+"...")

That said, if the var ShowMoreIsActive returns true, it will show your full text, if not it will substring your text from the first character (position 0) up to the 50th position (you can change it to your required necessity). 
I added the '...' at the end to be better understandable to the end user that there is more text available to be shown. 

Hope this helps you.
Best regards,

Edu


2019-03-12 12-28-20
Shivangi Thakur

Good idea, can try this way. Thanks!

2023-10-21 19-42-11
Tousif Khan
Champion

Hello

You would like to implement this on a input widget or a text area or you are showing the text in an expression?

Thanks
Tousif


2019-03-12 12-28-20
Shivangi Thakur

An expression inside list.

2023-10-21 19-42-11
Tousif Khan
Champion

I think This Forge will help you.

Solution is already here 

You can also use text ellipse function
and use it with If condition

Hope this works
Thanks
Tousif Khan

2019-03-12 12-28-20
Shivangi Thakur

Yeah saw this component but do not want to use for simple functionality so thought to ask if there is any other way to achieve this.

Thanks for your answer.

2024-06-19 09-49-45
edubaixo
Solution

Hi Shivangi

You can use a link or some other input type that changes a local variable that contains the state of the Show More value (ShowMoreIsActive - Boolean)

Then you can then encapsulate your text in an If expression like this:

If(ShowMoreIsActive,YourText,Substr(YourText,0,50)+"...")

That said, if the var ShowMoreIsActive returns true, it will show your full text, if not it will substring your text from the first character (position 0) up to the 50th position (you can change it to your required necessity). 
I added the '...' at the end to be better understandable to the end user that there is more text available to be shown. 

Hope this helps you.
Best regards,

Edu


2019-03-12 12-28-20
Shivangi Thakur

Good idea, can try this way. Thanks!

UserImage.jpg
Elis Jen

Yes, you can implement a "show more/show less" functionality for a large text field in OutSystems. You can achieve this using JavaScript and some custom CSS. Here's a basic outline:

  • HTML: Create a container for your text and a button.
  • CSS: Define styles for the expanded and collapsed states.
  • JavaScript: Toggle between these states on button click.

Here's a simple example:

HTML:

<div id="textContainer" class="collapsed">
      <span id="text">Your large text goes here...</span>
      <button onclick="toggleText()">Show More</button>
</div>

CSS:

.collapsed #text {

    display: -webkit-box;

    -webkit-line-clamp: 3; /* number of lines to show */

    -webkit-box-orient: vertical;

    overflow: hidden;

}

.expanded #text {

    display: block;

}

JavaScript:

function toggleText() {

    var container = document.getElementById("textContainer");

    if (container.classList.contains("collapsed")) {

        container.classList.remove("collapsed");

        container.classList.add("expanded");

        container.querySelector("button").innerText = "Show Less";

    } else {

        container.classList.remove("expanded");

        container.classList.add("collapsed");

        container.querySelector("button").innerText = "Show More";

    }

}


Integrate this code into your OutSystems application, and it should work as expected.

Thanks.

2024-05-14 06-52-28
Srigovindh-EONE
Solution

Hi Shivangi,

click here

Option 1: Use the TextEllipsis(value,30) function to shorten the text and add the attribute in the property panel.

title =value

Option 2: Use the substr() in Expression. For example, if (length(value)>30, substr(value, 0, 30), value) and add a tooltip inside the content with "..." and a tooltip expression (Value).

longtext.oml
2025-10-18 11-13-53
Ramesh subramanian

Hi ,

Please check OML File and should work as expected,

Thanks,

Ramesh


OSTest.oml
UserImage.jpg
Elis Jen

Okay, thanks! It might be an easier way...

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.