This discussion is archived
10 Replies Latest reply: Jan 22, 2013 5:55 PM by Howard (... in Training) RSS

Limit # of characters in the text field - report column.

robik Newbie
Currently Being Moderated
I have a report column where I would like to limit number or characters to 35.

If text field is used on the page max width attribute can be used however it is not available in the report column option.

Thanks in advance.

Rober
  • 1. Re: Limit # of characters in the text field - report column.
    Howard (... in Training) Pro
    Currently Being Moderated
    In the report item's Column Definition area, there should be a Column Width field. When I tried using it in Apex 4.2, it seemed to have no effect.

    There is also an Element width under Column Attributes -- which also had no effect!

    http://apex.oracle.com/pls/apex/f?p=21997:2 Dever Ima9Dever

    Edited by: Howard (DBA in Training) on Jan 17, 2013 1:26 PM

    (more) If you search the forum with "report column field width" you might find about 157 hits. I see lots of folks asking this question but I have yet to find a soution that works for me. You'd think this would be a simple thing -- and if it were the two fields noted above would likely have done the trick.

    Complications:
    1) If you have a big honking column name like BigHonkingColumnNameWithNoBreaks, you may have to put some breaks (bracket_openBRbracket_close) in it or the column may be forced to this width.
    2) Likewise, if your data is a long string XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX then you can have problems because there are no breaks where it can wordwrap.

    I haven't helped but there's some info that might prove helpful along the way.

    ????
    Howard
  • 2. Re: Limit # of characters in the text field - report column.
    Howard (... in Training) Pro
    Currently Being Moderated
    Rober,

    Have you had any luck so far? Did you look at some of those 157 other threads about report column width?

    *************
    Howard
  • 3. Re: Limit # of characters in the text field - report column.
    robik Newbie
    Currently Being Moderated
    Yes, I was able to find the solution

    Entering onFocus="javascript:this.maxLength=40;" in the Element Attributes of the column attribute.

    Robert
  • 4. Re: Limit # of characters in the text field - report column.
    Howard (... in Training) Pro
    Currently Being Moderated
    Well it does nothing for my report. Maybe it has to match up with something else I'm lacking. ??

    Best wishes then,
    Howard
  • 5. Re: Limit # of characters in the text field - report column.
    robik Newbie
    Currently Being Moderated
    What are you trying to set?

    In my case I have tabular form where few columns are editable and I want to control # of characters that users can enter there.

    Are you trying to do same thing?

    Let me know.

    Robert
  • 6. Re: Limit # of characters in the text field - report column.
    Howard (... in Training) Pro
    Currently Being Moderated
    As an example, I have a dinky little report with three columns. I'm trying to get it to squeeze the third column (ST_NM) so that it would either truncate or wrap. But no luck.

    See: http://apex.oracle.com/pls/apex/f?p=21997:3 Dever / Ima9Dever

    Howard
  • 7. Re: Limit # of characters in the text field - report column.
    fac586 Guru
    Currently Being Moderated
    robik wrote:
    Yes, I was able to find the solution

    Entering onFocus="javascript:this.maxLength=40;" in the Element Attributes of the column attribute.
    Tabular form text items appear to get arbitrary <tt>maxlength="2000"</tt> assigned that cannot be overridden using the column Element Attributes property. This appears to be a situation of long standing: +{message:id=906619}+

    This kind of workaround appears to be prevalent.

    If I cared about tabular forms I'd file a bug...
  • 8. Re: Limit # of characters in the text field - report column.
    Howard (... in Training) Pro
    Currently Being Moderated
    fac586,
    If I cared about ...
    I'm trying to understand what it says about a product -- I mean the support for it -- if a long standing problem such as this hasn't been fixed in 7 years?

    Okay, I'm not a good one to judge as I haven't used a lot of products. And maybe it's the nature of HTML, CSS, Javascript and XML. But I'd have to warn anyone considering using APEX that they need to be comfortable, and good, with work-arounds. Simple things like this don't work. And other things don't work intuitively. (E.g. Item default values aren't placed in the session state when rendered. Column limits don't.) I think that's a fair assessment.

    ??????
    Howard
  • 9. Re: Limit # of characters in the text field - report column.
    fac586 Guru
    Currently Being Moderated
    Howard (DBA in Training) wrote:
    Well it does nothing for my report. Maybe it has to match up with something else I'm lacking. ??
    Yes, like defining problems precisely enough to understand when you're actually talking about different things?

    Robert's issue relates to a text input item in a tabular form (aka "updateable report"), whilst you are talking about a standard report column. Just making a little more effort up front to provide a more detailed definition of the problem will enable members to better understand your situations and avoid confusion.
    Howard (DBA in Training) wrote:
    As an example, I have a dinky little report with three columns. I'm trying to get it to squeeze the third column (ST_NM) so that it would either truncate or wrap. But no luck.

    See: http://apex.oracle.com/pls/apex/f?p=21997:3 Dever / Ima9Dever
    In recent versions the Column Width property should work. Note that the width is specified in pixels (as described in the online help), not characters as used in Element Width property of form elements. (If you've been trying to set this to Robert's value of "35" it won't have any effect. As the column heading and several of the values are already wider than 35px, and given the defined behaviour of HTML tables and cells is to expand to fit their widest unbroken content, the column will always be rendered wider than 35px.) Try setting it to "90".

    Those hundreds of Re: Report column width mainly date from prior to the introduction of the built-in Column Width property, when the standard approach was to specify the width using the CSS Style property:
    display: block; width: 300px; 
    This actually sets the width of the content of the cells in the column. This is not always ideal when working with HTML tables. The best way to set the actual column width is applying a CSS width to the <tt>col</tt>, <tt>th</tt>, or <tt>td</tt> elements directly. The <tt>id/headers</tt> attributes most APEX templates include in report templates are useful as selectors in this case, using one of the page header CSS options:
    th[id="COLUMN_ALIAS"],
    td[headers="COLUMN_ALIAS"] {
      width: 10em;
    }
    Using one of the CSS techniques is more flexible than the Column Width property as the width can be specified using units other than pixels.

    For "big honking" strings that don't contain white space (what is the nature of this data? I keep asking every time this comes up, but no one ever provides an explanation), use <tt>overflow-wrap/word-wrap</tt>:
    td[headers="T_DNA"] {
      width: 300px;
      overflow-wrap: break-word;
    }
  • 10. Re: Limit # of characters in the text field - report column.
    Howard (... in Training) Pro
    Currently Being Moderated
    fac586,

    Thanks. You are certainly right. I didn't notice that Robert and I were talking about different report types(?). And I had no idea they would be handled different ways.

    But I have now tried setting Column Width at 50, 100, 200, and 300 all with no luck -- as mentioned in the other thread. {thread:id=2489469}

    Thank you for the code. I'll have to study up before I can use any of it. I have no idea where it goes right now.


    Robert,

    Excuse me for taking over your thread. I'll be going now.

    Kind regards,
    Howard

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points