2014-07-16 152 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