How to prevent ajax event on sorting if the table is empty?
How to prevent ajax event on sorting if the table is empty?
Is there a way to prevent firing ajax event on sorting if the table is empty? Here is what is happening at my end:
My initial data table is empty. The user is supposed to enter some search criteria and click the "Search" button which populates the DataTables grid with data matching the search criteria. However the user is able to bypass this design by simply clicking the sort icon on one of the columns. It seems that DataTables trigger an ajax event if the user tries to sort a column even if the grid is empty. My server side api is designed to return all the rows from the database table if the user doesn't enter any search criteria. So in the end, just with a click of sort icon, the user is able to pull all the rows from the database. I am thinking that the DataTables should not even trigger an ajax if the grid is empty. Similar thing is happening when the user changes the number of entries per page from say 10 to 25. Is there a way to fix this problem?