Search code examples
jsontwitter-bootstrapnullbootstrap-tabletablecell

Bootstrap table, dashes / hyphens in empty cells


I am using Wenzhixin's bootstrap-table module. (http://bootstrap-table.wenzhixin.net.cn/)

When I load my bootstrap table with JSON, and the field is null like this: "MyField": null

I see a dash, or hyphen ( - ) inserted into the empty table cell. What's the best way to turn this off?

Edit: example here https://jsfiddle.net/3k6qrswf/1/

    <table id="table" class="table">
  <thead>
    <tr>
      <th data-field="BookTitle">Title</th>
    </tr>
  </thead>             
</table>

    var testData = [
    {"BookTitle": "abc"},
  {"BookTitle": "def"},
  {"BookTitle": null}
];

$('#table').bootstrapTable({
            data: testData
        });

Thanks


Solution

  • You can use undefinedText option to do what you want, documentation here.

    $('#table').bootstrapTable({
        undefinedText: 'n/a',
        data: testData
    });
    

    Example: https://jsfiddle.net/3k6qrswf/2/.