cakephp / datasources

CakePHP Datasources
http://cakephp.org
237 stars 115 forks source link

ArraySource + Paginator #95

Closed mirko-pagliai closed 9 years ago

mirko-pagliai commented 10 years ago

This is not a real issue, this is rather a question. The plugin - and in particular the ArraySource datasource, supports the sorting provided by the Paginator component?

Using the Paginator component with ArraySource, I see that the paging works correctly, but not the sort (does not work nor the default sort, nor the sort specified by the user clicking on a sort link).

josegonzalez commented 10 years ago

It would have to sort the entire array in memory, wouldn't it?

lorenzo commented 10 years ago

As with any other operation using ArraySource

mirko-pagliai commented 10 years ago

I asked a question on StackOverflow, where I reported some information. Try to take a look: http://stackoverflow.com/questions/20972374/cakephp-arraysource-paginator

The "limit" condition works correctly. Even the paging works correctly: if I set the limit of records to be displayed and if I move between pages, I see the correct records (in the example, setting the limit of 2 records, on the first page I see the first two, the other two on the second page).

But if I click on a "sort()" link, there is no effect, I view the records in the original order. Even if I set the "order" condition in the pagination settings, the records are always shown in original order.

ADmad commented 10 years ago

@mirko-pagliai It's likely that ordering of records isn't implemented in the array source. The datasources in this repo are community maintained. So if you find a bug or need enhancement the best way would be to provide a patch (pull request) yourself.

mirko-pagliai commented 10 years ago

Sure, I know that. I just wanted to know if I'm doing something wrong or if the sorting is not supported ;-)

512banque commented 9 years ago

Fixed here: https://github.com/cakephp/datasources/pull/113

mirko-pagliai commented 9 years ago

Nice!

jadb commented 9 years ago

Closing this as there is a PR for it.