Winter CMS resources and help articles

Simple and to the point. Optimized by the community.

Add filtering to a ReorderController

0
by mjauvin, last modified on May 12th, 2021 - Previously published on OctoberTricks

Add this snippet to your controller's _reorder_toolbar.htm partial:

    <input name="filter-records" type="text" class="form-control icon search growable"
        data-request="onFilterRecords"
        data-track-input
    />

Add this to your Controller class:

    public function onFilterRecords()
    {   
        $reorderController = $this->asExtension('ReorderController');
        $reorderController->reorder();
        return [
            '#reorderRecords' => $reorderController->reorderMakePartial('records', ['records' => $reorderController->vars['reorderRecords']]),
        ];
    }

    public function reorderExtendQuery($query)
    {   
        if ($term = Input::get('filter-records')) {
            $query->where('name', 'like', "%$term%");
        }
    }

Discussion

0 comments

We use cookies to measure the performance of this website. Do you want to accept these cookies?