简体   繁体   中英

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. 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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