简体   繁体   English

具有分页和搜索功能的动态表

[英]Dynamic table with pagination and Search

I have a Dynamic table with only showing 10 records and using pagination to show the next 10 records. 我有一个动态表,仅显示10条记录,并使用分页显示接下来的10条记录。 I want a search function. 我想要一个搜索功能。 I follow this guide http://www.vonloesch.de/node/23 But instead I can only search on the first 10 records. 我遵循此指南http://www.vonloesch.de/node/23但我只能搜索前10条记录。

Any help is appreciated. 任何帮助表示赞赏。 Thanks 谢谢

This function will filter rows of the entire table based on each row's contents rather than just one cell as in the link you provided. 此函数将根据每一行的内容而不是您提供的链接中的一个单元格来过滤整个表的行。

// text => the text to search for
// _id => id of table to filter
// noOfHeaderRows => number of header rows :)
function filterTable( text, _id, noOfHeaderRows ) {

    var table = document.getElementById( _id ), contents, row;

    for (var r = noOfHeaderRows; r < table.rows.length; r++){

        row = table.rows[r];
        contents = row.textContent || row.innerText; 
        contents = contents.toUpperCase();
        text = text.toUpperCase();

        if( contents.indexOf( text ) > -1 ) {
            row.style.display = "";
        } else {
            row.style.display = "none";
        }

    }
}

Fiddle here 在这里摆弄

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM