Skip to content

Counts for total and filtered are the same #21

Description

@ghybs

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions