0

I am trying to display a string of JSON in the properly spaced out JSON format within a footable table <td> but it just removes all white space from the JSON string. I have tried to use the pre tag and although this retains the format it does not do what I need it to. Is there any means of keeping the formatting within a TD?

Here is my code:

@foreach (TinCan.Statement statement in Model.TinCanStatementList)
{
  <tr> 
    <td>@statement.actor.name <b>@statement.verb.display.ToJObject()["und"]</b> '@statement.target.ToJObject(TinCan.TCAPIVersion.V101)["definition"]["name"]["en-US"]'</td>  
    <td>@statement.ToJObject()</td>
  </tr>
}
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Jay
  • 3,012
  • 14
  • 48
  • 99

1 Answers1

0

Here's a simple example where the <pre> tag seems to work as expected.

<!DOCTYPE html>
<html>

<head>
  <link data-require="bootstrap-css@3.0.2" data-semver="3.0.2" rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css" />
  <link data-require="jqueryui@*" data-semver="1.10.0" rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.0/css/smoothness/jquery-ui-1.10.0.custom.min.css" />
  <link rel="stylesheet" href="footable.core.css" />
  <script data-require="jquery@*" data-semver="2.0.3" src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
  <script data-require="jqueryui@*" data-semver="1.10.0" src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.0/jquery-ui.js"></script>
  <script data-require="bootstrap@*" data-semver="3.0.2" src="//netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js"></script>
  <script src="footable.js"></script>
</head>

<body>
  <table class="table demo default footable" data-filter="#filter" data-filter-text-only="false">
    <thead>
      <tr>
        <th data-toggle="true" class="footable-first-column">Col 1</th>
        <th>Col 2</th>
        <th data-hide="phone,tablet">Col 3</th>
      </tr>
    </thead>
    <tbody>
      <tr class="" style="display: table-row;">
        <td></td>
        <td>
          <pre>{"menu": {
  "id": "file",
  "value": "File",
  "popup": {
    "menuitem": [
      {"value": "New", "onclick": "CreateNewDoc()"},
      {"value": "Open", "onclick": "OpenDoc()"},
      {"value": "Close", "onclick": "CloseDoc()"}
    ]
  }
}}</pre>
        </td>
        <td>Blah Blah Blah</td>
      </tr>
      <tr class="" style="display: table-row;">
        <td></td>
        <td>
          <pre>{"menu": {
  "id": "file",
  "value": "File",
  "popup": {
    "menuitem": [
      {"value": "New", "onclick": "CreateNewDoc()"},
      {"value": "Open", "onclick": "OpenDoc()"},
      {"value": "Close", "onclick": "CloseDoc()"}
    ]
  }
}}</pre>
        </td>
        <td>Blah Blah Blah</td>
      </tr>
      <tr class="" style="display: table-row;">
        <td></td>
        <td>
          <pre>{"menu": {
  "id": "file",
  "value": "File",
  "popup": {
    "menuitem": [
      {"value": "New", "onclick": "CreateNewDoc()"},
      {"value": "Open", "onclick": "OpenDoc()"},
      {"value": "Close", "onclick": "CloseDoc()"}
    ]
  }
}}</pre>
        </td>
        <td>Blah Blah Blah</td>
      </tr>
    </tbody>
  </table>
  <script type="text/javascript">
    $(function() {
      $('table').footable();
    });
  </script>
</body>
</html>

Here's a plunk that demonstrates this: http://plnkr.co/edit/qlKxfddZV7RYGISQkNWW

If this is not what you need, perhaps you could add some more detail to the question.

Jeff
  • 2,728
  • 3
  • 24
  • 41