Skip to main content
Question

Can I collapse a text field on reports?

  • May 15, 2013
  • 0 replies
  • 135 views

Is there is a way to collapse a multi line text field when it is displayed on reports? For example, a Description field can get pretty detailed and can make a report that displays it rather large and "un-pretty." I am wondering if there is a report or field setting that will allow the first couple of lines of a field to display with the option to click a "More..." link to expand the rest if needed.
This topic has been closed for replies.

  • Registered
  • May 16, 2013
Click the More or Less hyperlinks in the formula column to toggle the full text display:

Give Me More Or Less Bacon Ipsum
https://haversineconsulting.quickbase.com/db/bh4xjb385

[field] is a multiline text field while [formula] is a formula text field with some HTML allowed. The formula definition is in the following Pastie Database record:

Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=220

  • Registered
  • May 24, 2013
I would add some additional formatting to clean up the "more", "less" hyperlinks so that incase that there is no data in field and/or if the field if less than 100 characters the "more" or "less" doesn't show up.

If([field]="","",If(Length([field])>100,
var Text a = Left([field],100);
var Text b = NotLeft([field],100);

$a &
" <a onclick=\"$(this).hide();$(this).next().show().next().show();\">More</a>" &
" <span style='display:none'>" & $b & "</span>" &
" <a style='display:none' onclick=\"$(this).hide();$(this).prev().hide().prev().show();\">Less</a>",[field]))

The underlined code in this page is copyright by Dan Diebolt and may not be used without including my phone number (734-985-0721) and email address (dandiebolt@yahoo.com) in the footer of where you may want to use it.

Forum|alt.badge.img+14
  • Registered
  • May 28, 2013
I use this code for these kinds of problems.

If(Length([Comments])>100,Left([Comments],100)&"...<br><a href="&URLRoot()&"db/"&Dbid()&"?a=dr&rid="&[Record ID#]&"&dfid=10>more</a>",[Comments])

Change the 100 to represent the number of characters that you need to display in the report before the "more" button becomes visible.

(Remember to turn on the HTML in the Formula Text field) - usually I label these fields [Comments (Reports)] so it is more obvious which fields should be used for report building

  • Registered
  • November 22, 2013
can this be modified to also show 'less' after 'more' is clicked?

  • Registered
  • November 22, 2013
The one above that I posted will give you a button at the end of the statement and allow you to show less as well.

  • Registered
  • November 22, 2013
I tried yours/dandiebolt_QB_Pirate version but they remove line breaks and group it all together as a single paragraph.  The simpler version above doesn't do that.  Unfortunately my team are complaining that it is harder to follow the flow of appended text without line breaks between each dated entry.  ** I am a complete HTML novice.  Any suggestions would be appreciated.

This is a great solution, but I have the same question as PCalabrese. Can you use the Left() formula (or something else) and not lose the line breaks?

Improved version: http://pastie.org/10963821

I figured it out with a lot of googling. Copy everything below and replace [Notes] with your field name.

If([Notes]="", "",      //If [Notes] is blank, display nothing
If(Length([Notes])>300,     //If [Notes] is greater than 300 characters
var Text a = "<span id=&quot;Detail&quot;'><pre style='font-family:&quot;Helvetica&quot;,&quot;Tahoma&quot;,&quot;Arial&quot;,&quot;sans-serif&quot;!important;font-size:100%!important;white-space:pre-wrap!important;'>"&Left([Notes],300)&"</pre></span>";
var Text b = "<span id=&quot;Detail&quot;'><pre style='font-family:&quot;Helvetica&quot;,&quot;Tahoma&quot;,&quot;Arial&quot;,&quot;sans-serif&quot;!important;font-size:100%!important;white-space:pre-wrap!important;'>"&NotLeft([Notes],300)&"</pre></span>";

//"var Text a" shows the first 300 characters from [Notes]
//"var Text b" shows the remaining text

//The following script is the "more/less" function
$a &
" <a onclick=\"$(this).hide();$(this).next().show().next().show();\">Show more</a>" &
" <span style='display:none'>" & $b & "</span>" &
" <a style='display:none' onclick=\"$(this).hide();$(this).prev().hide().prev().show();\">Show less</a>",
"<span id=&quot;Detail&quot;'><pre style='font-family:&quot;Helvetica&quot;,&quot;Tahoma&quot;,&quot;Arial&quot;,&quot;sans-serif&quot;!important;font-size:100%!important;white-space:pre-wrap!important;'>"&[Notes]&"</pre></span>"))     //If [Notes] is less than 300 characters, display [Notes]

Forum|alt.badge.img+14
  • Registered
  • November 17, 2016
Thank you for posting this; I really like this alternative solution to the pop up modal that displays on screen.  The only downside of showing the "remaining" characters separately is that the row splits at the character limit which could be in the middle of a sentence, paragraph or text-append name/date entry value.  If you could hide $a and show the "entire" note as $b; that would be ideal.

Yeah I noticed that too. It isn't too bad, but ideally would be better if it didn't split like that. Your last point is a good idea, I may fiddle with it to see if it works out.

[mention://2365038 @Matthew] Thanks!!

Okay guys I fixed the line splitting issue that [mention://537 @QuickBasePros_IDS] brought up.
New code is here: http://pastie.org/10963821

Forum|alt.badge.img+14
  • Registered
  • November 17, 2016
Thanks Matthew - great job on modifying it; and for sharing!

  • Registered
  • November 17, 2016
I can't believe I contributed to this solution. I am enabling bad practices. I only did it as a attention grabbing stunt. That code will surely break when Mercury is released as it is very dependent on the fine structure of QuickBase's HTML.

On the other hand if it works it works.

_\_(_)_/__ __\_(_)_/__ __\_(_)_/__ __\_(_)_/__ __\_(_)_/__

Well [mention://513 @dandiebolt_QB_Pirate] you definitely got our attention!
It may break with the Mercury rollout, but there are lots of unconventional solutions on the Quickbase Community that will probably stop working in Mercury as well. And who knows when that'll be............................