Nagaraju Dirsipam
Nagaraju Dirsipam

Reputation: 13

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

Upvotes: 1

Views: 737

Answers (1)

DudiDude
DudiDude

Reputation: 413

Try

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

Upvotes: 1

Related Questions