2014-07-16 88 views
1

我有一個datatable的問題。當我的表加載它的所有作品(篩選器下拉菜單顯示)時,搜索顯示,但'prev'和'next'之間的數字不會。彙總(x記錄的x)也不會。但是,只要我進行搜索,一切正常顯示。JQuery Datable信息顯示不正確

表的代碼是:

<table id="propertieslist" class="admintable"> 
       <thead> 
        <tr> 
         <th colspan="2"></th> 
         <th class="divider"></th> 
         <th>Type</th> 
         <th>Region</th> 
         <th>Address</th> 
         <th class="divider"></th> 
         <th>Owner</th> 
         <th>Status</th> 
        </tr> 
       </thead> 
       <tbody> 
        {% for property in properties %} 
        <tr> 
         <td><a href="{{ path('view_property', {'id' : property.id}) }}">{{ property.id }}</a></td> 
         <td>{{ property.propertyName }}</td> 
         <th class="divider"></th> 
         <td>{{ property.type }}</td> 
         <td>{{ property.propertyRegion }}</td> 
         <td>{{ property.propertyAddr1 }}</td> 
         <th class="divider"></th> 
         <td>{{ property.owner.ownerName }}</td> 
         <td><span class="label {{ property.status }} label-mini">{{ property.status }}</span></td> 
        </tr> 
        {% endfor %} 
       </tbody> 
      </table> 

生成表輸出:

<table class="admintable dataTable" id="ownerslist" aria-describedby="ownerslist_info"> 
       <thead> 
       <tr role="row"><th colspan="2" rowspan="1"></th><th class="sorting" role="columnheader" tabindex="0" aria-controls="ownerslist" rowspan="1" colspan="1">Email</th><th class="sorting" role="columnheader" tabindex="0" aria-controls="ownerslist" rowspan="1" colspan="1">Phone</th><th class="divider sorting" role="columnheader" tabindex="0" aria-controls="ownerslist" rowspan="1" colspan="1"></th><th class="sorting" role="columnheader" tabindex="0" aria-controls="ownerslist" rowspan="1" colspan="1"># Props.</th><th class="sorting" role="columnheader" tabindex="0" aria-controls="ownerslist" rowspan="1" colspan="1"># Bookings</th><th class="divider sorting" role="columnheader" tabindex="0" aria-controls="ownerslist" rowspan="1" colspan="1"></th><th class="sorting" role="columnheader" tabindex="0" aria-controls="ownerslist" rowspan="1" colspan="1">Proforma</th></tr> 
       </thead> 

      <tbody role="alert" aria-live="polite" aria-relevant="all"><tr class="odd"> 
         <td class=" "><a href="#">2</a></td> 
         <td style="white-space: nowrap" class=" ">Adam Martin</td> 
         <td class=" ">[email protected]</td> 
         <td style="white-space: nowrap" class=" ">33</td> 
         <th class="divider "></th> 
         <td class=" ">2</td> 
         <td class=" ">23</td> 
         <th class="divider "></th> 
         <td class=" ">$98.23</td> 
        </tr><tr class="even"> 
         <td class=" "><a href="#">3</a></td> 
         <td style="white-space: nowrap" class=" ">Alpine Holiday Houses</td> 
         <td class=" ">[email protected]</td> 
         <td style="white-space: nowrap" class=" ">1111</td> 
         <th class="divider "></th> 
         <td class=" ">2</td> 
         <td class=" ">23</td> 
         <th class="divider "></th> 
         <td class=" ">$98.23</td> 
        </tr></tbody></table> 

和DataTable INIT用:

$(document).ready(function() { 
     $('#ownerslist').dataTable(
      { 
       "bSort" : false 
      } 
     ); 
    }); 

理解任何想法。 感謝

+0

如果您發佈表HTML完全按照文件(而不是呈現在瀏覽器之一)將幫助我們更多的,請參閱我在說什麼http://jsfiddle.net/DJBme/ –

+0

我已經添加了表格的源代碼。它使用樹枝。謝謝 – tweakmag

回答

1

有2個問題,在您的代碼:

第一個問題

數據表不支持colspan,因爲它是,你需要從第一th刪除或遵循什麼被提及在這樣的回答:DataTables - Not working when added colspan for the last column

問題二:

「propertyName」缺少一個標題列,如果錯過了標籤,我不能說這是錯誤的。

結果與修復應用:

<table id="ownerslist" class="admintable"> 
<thead> 
    <tr> 
     <th></th> <!-- removed colspan --> 
     <th></th> <!-- added th --> 
     <th class="divider"></th> 
     <th>Type</th> 
     <th>Region</th> 
     <th>Address</th> 
     <th class="divider"></th> 
     <th>Owner</th> 
     <th>Status</th> 
    </tr> 
</thead> 
<tbody>{% for property in properties %} 
    <tr> 
     <td><a href="{{ path('view_property', {'id' : property.id}) }}">{{ property.id }}</a> 
     </td> 
     <td>{{ property.propertyName }}</td> 
     <th class="divider"></th> 
     <td>{{ property.type }}</td> 
     <td>{{ property.propertyRegion }}</td> 
     <td>{{ property.propertyAddr1 }}</td> 
     <th class="divider"></th> 
     <td>{{ property.owner.ownerName }}</td> 
     <td><span class="label {{ property.status }} label-mini">{{ property.status }}</span> 
     </td> 
    </tr>{% endfor %}</tbody> 
</table> 

FIDDLE:http://jsfiddle.net/DJBme/2/

+0

謝謝。該標籤旨在不存在。但刪除了colspan的作品。謝謝。 – tweakmag