Since you are using javascript to query/filter the data
which is displaying on the screen(gridview) , Obviously it will filter only the data available on the screen(gridivew) based on your
if conditions
.
This is how javascript works
When you are using
pagination
(
eg 10 records per page), The
Server
will transfer only
10 records to the web browser in an
HTML Table[
^] format and you code will query that 10 records only, not the entire dataset.
if you want to filter the entire data, you should remove the pagination, so that the whole dataset will be transferred to the browser in an HTML Table format.
Your Javascript code has the Control over
DOM [
^]only, not to the server data, if you want to do the filtering over server data by using Javascript then you will have to use
JQuery AJAX[
^] to get the data asynchronously and based on the
JSON [
^] result data, build the
HTML table dynamically[
^].
This is how you can resolve your issue.