足部错误:错误:未提供列,未显示表

时间:2016-11-23 16:35:12

标签: jquery css jsp footable

我的.jsp文件中有这个表:

<table class="footable table table-striped table-hover" id="clientTable" data-page-size="10" data-filter=#filter>
    <tbody id="idbody">
        <tfoot>
            <tr>
                <td colspan='6'>
                    <ul class='pagination pull-right'></ul>
                </td>
            </tr>
        </tfoot>
     </tbody>
</table>

我想填充来自具有此代码的ajax请求的数据,并且我动态地填充表格:

$.ajax({
  type: 'POST',
  url: 'GetClientSearchResultServlet',
  success: function (data) {
    var jsonString = JSON.parse(data);

    $.each(jsonString, function(k, v) {
      var $option= "<tr id='tr"+v.id+"'></tr>";
      $('#idbody').append( $option );
      $option= "<td class='client-avatar'><i class='fa fa-user'>Ola</i></td>";
      $('#tr'+v.id).append( $option );
      $option="<td><a data-toggle='tab' href='#contact-"+v.id+"' onclick=userDetail("+v.id+") class='client-link' id="+v.id+">"+v.name+"</a></td>";
      $('#tr'+v.id).append( $option );
      $option="<td>"+v.local+"</td>";
      $('#tr'+v.id).append( $option );
      $option="<td class='contact-type'><i class='fa fa-envelope'> </i></td>";
      $('#tr'+v.id).append( $option );
      $option="<td>"+v.email+"</td>";
      $('#tr'+v.id).append( $option );
      $option="<td class='client-status'><span class='label pull-right'>"+v.entityType+"</span></td>";
      $('#tr'+v.id).append( $option );
    });
  }
});

当我运行它时,它会给出错误:&#34; FooTable:在初始化期间抛出未处理的错误。错误:没有提供列和#34;。但是,如果我在页面上检查元素,表格将显示在代码中,其中包含数据库中的数据,但不会显示在页面上。有什么帮助吗?

1 个答案:

答案 0 :(得分:0)

我认为这是因为您没有定义任何表标题<th>

Per FooTables的文档(https://fooplugins.github.io/FooTable/docs/getting-started.html)您的表应格式如下:

<table>
    <thead>
        ...
        <tr>
            <th data-breakpoints="xs">ID</th>
            <th>First Name</th>
            <th>Last Name</th>
            <th data-breakpoints="xs">Job Title</th>
            <th data-breakpoints="xs sm">Started</th>
            <th data-breakpoints="xs sm md">DOB</th>
        </tr>
    </thead>
    ...
</table>