Discussions

Expand all | Collapse all

Can I collapse a text field on reports?

Matthew Matthew11-15-2016 19:36

Edgar_Solutions Edgar_Solutions11-16-2016 20:12

  • 1.  Can I collapse a text field on reports?

    Posted 05-15-2013 13:16
    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.


  • 2.  RE: Can I collapse a text field on reports?

    Top
    Contributor
    Posted 05-16-2013 00:04
    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


  • 3.  RE: Can I collapse a text field on reports?

    Top
    Contributor
    Posted 05-24-2013 14:13
    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.


  • 4.  RE: Can I collapse a text field on reports?

    Silver
    Contributor
    Posted 05-28-2013 13:24
    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


  • 5.  RE: Can I collapse a text field on reports?

    Top
    Contributor
    Posted 11-21-2013 22:02
    can this be modified to also show 'less' after 'more' is clicked?


  • 6.  RE: Can I collapse a text field on reports?

    Top
    Contributor
    Posted 11-21-2013 22:04
    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.


  • 7.  RE: Can I collapse a text field on reports?

    Top
    Contributor
    Posted 11-21-2013 22:09
    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.


  • 8.  RE: Can I collapse a text field on reports?

    Posted 02-04-2016 13:51
    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?


  • 9.  RE: Can I collapse a text field on reports?

    Posted 11-15-2016 19:36
    Improved version: http://pastie.org/10963821


  • 10.  RE: Can I collapse a text field on reports?

    Posted 11-16-2016 17:42
    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]


  • 11.  RE: Can I collapse a text field on reports?

    Silver
    Contributor
    Posted 11-16-2016 19:26
    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.


  • 12.  RE: Can I collapse a text field on reports?

    Posted 11-16-2016 20:01
    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.


  • 13.  RE: Can I collapse a text field on reports?

    Posted 11-16-2016 20:12
    [mention://2365038 @Matthew] Thanks!!


  • 14.  RE: Can I collapse a text field on reports?

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


  • 15.  RE: Can I collapse a text field on reports?

    Posted 01-09-2019 16:54
    The link is no longer working. Could you post the pastie again that corrects the splitting issue?


  • 16.  RE: Can I collapse a text field on reports?

    Silver
    Contributor
    Posted 11-16-2016 20:39
    Thanks Matthew - great job on modifying it; and for sharing!


  • 17.  RE: Can I collapse a text field on reports?

    Top
    Contributor
    Posted 11-16-2016 21:02
    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.

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


  • 18.  RE: Can I collapse a text field on reports?

    Posted 11-16-2016 21:14
    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............................