如果我的数据中没有数据,我会收到此错误:
Uncaught TypeError: Cannot read property 'rows' of undefined
如果表中没有数据,如何禁用表排序器:
我是这样使用tablesorter
的:
$(document).ready(function() {
$("table").tablesorter();
// set sorting column and direction, this will sort on the first and third column the column index starts at zero
var sorting = [[0,0],[2,0]];
// sort on the first column
$("table").trigger("sorton",[sorting]);
// return false to stop default link action
return false;
});
表如下所示:
<table border="0" width="100%" cellpadding="0" cellspacing="0" id="product-table" class="tablesorter">
<thead>
<tr>
<th width="5%" class="table-header-left"><a href=""><span></span></a></th>
<th width="25%" class="table-header-repeat line-left"><a href=""><span>File Name</span></a></th>
<th width="15%" class="table-header-repeat line-left"><a href=""><span>Type</span></a></th>
<th width="15%" class="table-header-repeat line-left"><a href=""><span>Size</span></a></th>
<th width="20%" class="table-header-repeat line-left"><a href=""><span>Date Updated</span></a></th>
<th width="20%" class="table-header-options line-left"><a href=""><span>Source</span></a></th>
</tr>
</thead>
{% csrf_token %}
{% load endless %}
{% paginate limit files %}
{{ endless_pagination.utils.get_elastic_page_numbers }}
{% for choice in files %}
<tr>
<td><input type="checkbox" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}" /></td>
<td><label for="choice{{ forloop.counter }}">{{ choice.file_name }}</label></td>
<td>{{ choice.type }}</td>
<td>{{ choice.size }}</td>
<td>{{ choice.end_date }}</td>
<td>{{ choice.source }}</td>
</tr>
{% endfor %}
</table>