• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

NAB Grids interpret table data as HTML

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • NAB Grids interpret table data as HTML

    I ran into this bug while trying to display data from one of our tables and the data contains a "less than" symbol ('<') in the field. It wasn't showing up in the display and the browser console was reporting some strange errors. I tracked it down to the grid trying to interpret this input data as HTML. I can manually change this table to something like '<b>My String</b>' and it will spit out My String is bold font rather than taking the string as-is to display.

    I believe this to be a bug but if this is intended behavior, is there some setting or procedure I can use to switch this?

  • #2
    I would suggest you add the below custom formatting for the column(s) in question so the your value is encoded. That way the browser doesn't try to interpret it

    Code:
    // encode string so browser doesn't think its markup
    //
    if (!Valence.isEmpty(v) && Valence.isString(v)) {
        return String(v).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
    }
    return v;
    I have added this to our feature request list to possibly be an option on the column configuration

    Comment


    • #3
      Originally posted by Johnny Major View Post
      I would suggest you add the below custom formatting for the column(s) in question so the your value is encoded. That way the browser doesn't try to interpret it

      Code:
      // encode string so browser doesn't think its markup
      //
      if (!Valence.isEmpty(v) && Valence.isString(v)) {
      return String(v).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
      }
      return v;
      I have added this to our feature request list to possibly be an option on the column configuration
      I ended up using the built-in ExtJS library encoder for the same result in a custom formatter. It's much shorter and probably more robust than a hand built one we would do.

      Code:
      return Ext.util.Format.htmlEncode(v);

      Comment

      Working...
      X