jquery
  • css
  • jsp
  • footable
  • 2016-11-23 123 views 0 likes 
    0

    我在.jsp文件有這個表:Footable錯誤:錯誤:沒有列提供的,沒有顯示錶

    <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); 
        }); 
        } 
    }); 
    

    當我運行它,它給出了錯誤:「FooTable:未處理的錯誤初始化錯誤期間拋出:不提供列」。但是,如果我檢查頁面上的元素,表格會顯示在代碼中,並顯示來自我的數據庫的數據,但不顯示在頁面上。任何幫助?

    回答

    0

    我相信這是因爲你沒有任何表頭<th>定義。

    每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> 
    
    相關問題