Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Counts for total and filtered are the same #21

Open
ghybs opened this issue Mar 7, 2018 · 0 comments · May be fixed by #22
Open

Counts for total and filtered are the same #21

ghybs opened this issue Mar 7, 2018 · 0 comments · May be fixed by #22

Comments

@ghybs
Copy link

ghybs commented Mar 7, 2018

When using DataTables "search" input field, node-datatable correctly builds 2 count queries (recordsTotal and recordsFiltered).
However, those 2 queries are always identical.

Live demo: https://plnkr.co/edit/PZiw9h5z0AgqSAQIfcXM?p=preview

It seems that the buildCountStatement private function always uses the search string through the buildWherePartial private function:

function buildCountStatement(requestQuery) {
var dateSql = buildDatePartial();
var result = "SELECT COUNT(";
result += self.sSelectSql ? "*" : (self.sCountColumnName ? self.sCountColumnName : "id");
result += ") FROM ";
result += self.sFromSql ? self.sFromSql : self.sTableName;
result += buildWherePartial(requestQuery);

It looks like previously the search string had to be explicitly provided to produce a different result:

* @param searchString If specified then produces a statement to count the filtered list of records.
* Otherwise the statement counts the unfiltered list of records.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant