Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    ListGrid: '\n' converted to '<br>' even if 'FixedRecordHeights:true'.

    Hi Isomorphic,

    I have one strange problem. My data contains '\n'
    Code:
    TEST_FIELD:"SmartPad AG\ntest\ntest\nasadasdf (Pan Peter)",
    and this is converted to '<br>' as display value of ListGridField.

    Click image for larger version

Name:	br.PNG
Views:	97
Size:	4.7 KB
ID:	261164

    ListGrid property "FixedRecordHeights" is set to "true".

    Do you have any assumptions about where this comes from?
    My expectation is that '\n' will simply be ignored when displayed in ListGrid if "FixedRecordHeights" is set to true.
    SmartClient Version: v12.0p_2019-12-14/PowerEdition Deployment (built 2019-12-14)

    Best,
    Pavo

    #2
    You probably have escapeHTML set to true or you may have a formatter installed.

    How we handle the value is unrelated to fixedRecordHeights as vertical clipping is sometimes desirable for HTML content embedded in a field.

    Comment


      #3
      Hi Isomorphic,

      I have escapeHTML set to true.
      But I need to have it because someone could type in a Javascript command, and that command would be executed if escapeHTML is set to false, right?

      I think it would be great to have something like "escapeLineBreak" as well.
      I could do it manually, this way
      Code:
          public class CommentFormatter implements CellFormatter {
              @Override
              public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                  if (value != null) {
                      String newValue = value.toString().replaceAll("\r\n", " ").replaceAll("\r|\n", " ");
                      return newValue;
                  }
                  return null;
              }
          }
      what is not nice at all.

      Having a (ListGrid or ListGridField) setting for this case would be great as well.

      Best,
      Pavo

      Comment


        #4
        We see the issue you reported and will be adding a new property to allow targeted control over conversion of line breaks.

        Comment


          #5
          We've added a new property ListGridField.skipLineBreaks that skips conversion of line break character sequences when escapeHTML is active on a ListGridField. It's present in SC 12.0 and later releases as of the nightly builds dated 2020-02-28.

          Comment


            #6
            Hi Isomorphic,

            a new property really helps, thank you very much!

            Best,
            Pavo

            Comment

            Working...
            X