[CLOSED] Newlines not showing in GridPanel

  1. #1

    [CLOSED] Newlines not showing in GridPanel

    I'm loading a GridPanel with the results of a SQL Server query (converted to JSON). One of the columns has values separated by newlines CHAR(10)+CHAR(13). For some reason in the GridPanel these are just showing up as spaces, even though the same results loaded in Excel do show the newlines correctly.

    Here is sample JSON data:
    [
    {"APPLICATION":"Missing Application Mapping - ","RECORD_PRODUCT_TYPE":"HW","CURRENT_EOL":"4 - HP BLADESYSTEM BL25P\n5 - IBM BLADECENTER HS20\n2 - IBM P5 P520\n1 - IBM XSERIES 360\n4 - SUN SUN FIRE 6800\n1 - SUN SUN FIRE V440\n"},
    {"APPLICATION":"Missing Application Mapping - ","RECORD_PRODUCT_TYPE":"WEB","CURRENT_EOL":"1 - IBM WEBSPHERE PORTAL SERVER\n1 - JPMC FAST APP STACK\n",}
    ]
    Not sure the right way to go about this but I've already tried using "\n" and "<br>" in the SQL query instead of the newline characters. That didn't work. Apparently JSON converts the SQL newline characters to "\n", so maybe there's a way of replacing the "\n" with "<br>"?
  2. #2
    Hi @elisa,

    You could use such a Renderer:
    <ext:Column runat="server" Text="Test" DataIndex="test">
        <Renderer Handler="return value.replace('\n', '<br/>');" />
    </ext:Column>
    Though it might be very expensive operation in the performance aspect. Especially, if the strings are long and there are many rows in the grid. Maybe, there is a better solution, but I don't know where "\n" comes from to suggest something concrete more.
  3. #3
    Quote Originally Posted by Daniil View Post
    You could use such a Renderer:
    <ext:Column runat="server" Text="Test" DataIndex="test">
        <Renderer Handler="return value.replace('\n', '<br/>');" />
    </ext:Column>
    Or
    <Renderer Format="Nl2br" />
    http://docs-origin.sencha.com/extjs/...t-method-nl2br
  4. #4
    This worked perfectly. Thanks!

Similar Threads

  1. [CLOSED] Showing copy / paste information in a gridpanel
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 22
    Last Post: May 17, 2012, 12:15 PM
  2. Replies: 1
    Last Post: Apr 23, 2012, 8:00 AM
  3. [CLOSED] GridPanel showing only last record
    By FAS in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 28, 2012, 12:47 PM
  4. Replies: 6
    Last Post: Feb 09, 2010, 4:32 PM
  5. [CLOSED] gridpanel not showing any rows
    By idrissb in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: May 19, 2009, 7:58 AM

Tags for this Thread

Posting Permissions