简体   繁体   中英

Filter datatable rows based on external drop down

I have a external drop down with values 1,2,3 etc

Im trying to filter datatable rows based on drop down. But its working only if I search 1, if the table also has 101 as column value, it even displays that.

I want to display the exact rows matching the column value

Here is mycode

var ctId = obj.value; // it will get 1,2, 3 etc based on selected 
if(ctId == "") { // display all rows
    theDatatable.columns(0).search("").draw();
} else {
    theDatatable.columns(0).search(ctId).draw(); // This is displaying even the rows having column 101
}

Where im missing

尝试

theDatatable.columns(0).search('^'+ctId+'$', true, false).draw();

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