admin管理员组文章数量:1410674
I'm trying to get the count of the number of rows on the current dataTables page. If I do this:
alert($('.tableViewer tbody tr').length)
It gives me the a non-accurate row count (I think it adds the current page and the last one?).
Anyway, I'm just trying to get the row count on the page I'm actually on. Does anyone know how to do this?
Here's my delete button:
function fnDelete(elem){
if (selected.length>0) {
var c;
c = confirm('Are you sure you want to delete the selected ${displayTableName}?');
if (c) {
// Create delete url from editor url...
var deleteURL = (urlstr.substring(0, urlstr.lastIndexOf('/') + 1)) + "delete.do";
alert($('.tableViewer tbody tr').length)
deleteRecord(deleteURL,selected[0]);
alert($('.tableViewer tbody tr').length)
if ( $('.tableViewer tbody tr').length === 1) {
setTimeout(function() { oTable.fnPageChange('last'); }, 100);
}
}
}
}
I'm trying to get the count of the number of rows on the current dataTables page. If I do this:
alert($('.tableViewer tbody tr').length)
It gives me the a non-accurate row count (I think it adds the current page and the last one?).
Anyway, I'm just trying to get the row count on the page I'm actually on. Does anyone know how to do this?
Here's my delete button:
function fnDelete(elem){
if (selected.length>0) {
var c;
c = confirm('Are you sure you want to delete the selected ${displayTableName}?');
if (c) {
// Create delete url from editor url...
var deleteURL = (urlstr.substring(0, urlstr.lastIndexOf('/') + 1)) + "delete.do";
alert($('.tableViewer tbody tr').length)
deleteRecord(deleteURL,selected[0]);
alert($('.tableViewer tbody tr').length)
if ( $('.tableViewer tbody tr').length === 1) {
setTimeout(function() { oTable.fnPageChange('last'); }, 100);
}
}
}
}
Share
Improve this question
asked Oct 26, 2012 at 17:52
streetlightstreetlight
5,97813 gold badges66 silver badges102 bronze badges
3
-
1
Is it possible that there are hidden rows?
$('.tableViewer tbody tr:visible').length
– JoeFletch Commented Oct 26, 2012 at 17:53 - you are doing the right way actually. inspect your dom elements – Mustafa Genç Commented Oct 26, 2012 at 17:55
- @JoeFletch -- that was exactly what I was looking for! Thank you very much! If you write it in an answer I'll be sure to pick it as the correct one and upvote you as well. This was driving me crazy! – streetlight Commented Oct 26, 2012 at 17:56
1 Answer
Reset to default 6The tr
elements may be on the page, but not visible. Try this!
$('.tableViewer tbody tr:visible').length
本文标签: javascriptGet number of rows on specific datatables pageStack Overflow
版权声明:本文标题:javascript - Get number of rows on specific datatables page? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744939509a2633398.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论