This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hi, is there a way to select all the filtered records in the list and not just those of the displayed page from pagination?
Last updated
I mean from the UI, if I filter the list of records for example by date range and I have 800 paginated records in n pages and I want to perform an action on them by using a button added to the toolbar how can I select them all and not just those displayed on the current page? thanks mjauvin
It depends how you implement this. If it is an action based on the selected records, you obviously cannot apply this to all records. How do you currently implement this "action" ?
I create a pdf using the data of the selected records, the customer filters them by period, selects them and through the button added to the toolbar I call the relative method in the controller that generates the pdf and returns it for download, everything works fine but I would need a "ALL" in the definition of how many records are to be shown in paging
Last updated
You might need to use filter dependencies as explained here:
https://octobercms.com/docs/backend/lists#filter-scope-dependencies
mmm...I don't think so, maybe I haven't explained myself well, sorry, I already filter them correctly, my problem is that I have to select (or be able to pass them in some way to the method) all the records after they have been filtered
I understand, but you also said you need to select ALL currently filtered records... do you need to select all or be able to select SPECIFIC records amongst ALL THE CURRENTLY FILTERED RECORDS?
Ok, I get what you're trying to achieve now... I'll investigate on the best approach to do this and report back.
Last updated
Ok, I figured it out... add this method to your controller:
public function onGetFilteredRecords()
{
$this->makeLists();
$listWidget = $this->asExtension('ListController')->listGetWidget();
$query = $listWidget->prepareQuery();
$records = $query->get();
// do something with $records
debug('We have ' . count($records) . ' records');
foreach ($records as $record) {
// do something with $record
}
}
And just call this method in your button's action. (e.g. below):
<button
class="btn btn-default"
data-request="onGetFilteredRecords">
Get Filtered Records
</button>
mjauvin said:
Ok, I figured it out... add this method to your controller:
public function onGetFilteredRecords() { $this->makeLists(); $listWidget = $this->asExtension('ListController')->listGetWidget(); $query = $listWidget->prepareQuery(); $records = $query->get(); // do something with $records debug('We have ' . count($records) . ' records'); foreach ($records as $record) { // do something with $record } }
And just call this method in your button's action. (e.g. below):
<button class="btn btn-default" data-request="onGetFilteredRecords"> Get Filtered Records </button>
Wow! mjauvin you're awesome thank you very much!
1-12 of 12