contributte / contributte/datagrid

Aggregation in combination with paginating

Open
#974 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

T: Bug
Dominant language
PHP
Stars
296
Forks
215
PR merge metrics
No merged PRs in 30d

Description

Hi,

aggregation function (like FunctionSum) can be define only in some context (for all records in data model, for filtered data model or for paginated data model). This is great.

But if we want to aggregate data on one page (paginated data model) and choose "All records in one page", total sum is zero, because onAfterPaginated in DataModel is not called if paginator is not trigged. And if we change context to filtered data model (called always), we cannot sum on one page.

Possible solution:

  • allow IAggregationFunction::$dataType to contain more values (together paginated and filtered) and correct TDataGridAggregationFunction to check multiple values (bitwise operators, in_array, whatever) - pity will be twice to aggregate
  • or call onAfterPaginated in DataModel also if paginator is not present - pity if this can break something
  • or add new onAfterProcessing in DataModel and associate paginated data model of aggregation function with onAfterProcessing instead of onAfterPaginated

The third one is the greatest, but it needs the most coding.

Milan

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing DataModel's onAfterPaginated behavior and how IAggregationFunction::$dataType is evaluated by TDataGridAggregationFunction. Compare the proposed handling for filtered and paginated data, then define which lifecycle behavior preserves aggregation for a paginated data model without a paginator. Done means "All records in one page" produces the expected aggregate instead of zero.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.