Trim a field for static display

0
What' the best way to do this?    I have a field that's 1000 characters long, I want to display a static version of it but only show the first 50 characters.
asked
4 answers
2

Alternatively (don't know if it is something you considered, whether the 50 number is a hard requirement or if it's based on the max width that it represents) but you can also use CSS to determine shown length, by showing ellipses to indicate there is content that is not shown. Only 'but': you would have to be able to place your field in a container, depending on the way you display the data I'm not sure if that's an option. Some CSS needs to go on the container, some on the data element. An example can be found here: https://css-tricks.com/snippets/css/truncate-string-with-ellipsis/

 

answered
1

Or try this widget: https://appstore.home.mendix.com/link/app/27520/Mendix/Show-More-/-Show-Less

answered
0

You could introduce a new attribute that is filled by an on-change microflow triggered by a change of your 1000characters attribute. You can call this attribute _Screen_YourAttributeName to show that it is only used for your screen.

 

You can fill the attribute with the string function call "Substring":  

substring('thisismystring', 0,50)

 

Albert

answered
0

Hi Jim,

We have the same situation and have used an extra attribute to be displayed in a datagrid.

This is how we fill that attribute:

if length($Remark) > 50 
  then substring($Remark,0,47)+'...'
else 
  $Remark

Hope that helps.

answered