Grids icon indicating copy to clipboard operation
Grids copied to clipboard

How to set params to pagination page

Open nhoctanker opened this issue 7 years ago • 8 comments

Hi ! i'm not use filter of grid , i have grid and other form . http://prntscr.com/evfa4o When i search and then next page the request params reset . how to set that on next page ?

nhoctanker avatar Apr 12 '17 07:04 nhoctanker

In your page there are two form so basically you cannot submit them at the same time .

workaround

Using only html5 you can ( ex. using grid name as doc)

  • do not include your filters input inside a form <input name="doc[filters][your_filter_name]" form="my_grid">
  • reference them in the grid form ( you must create a template of grid.php and give it an ID ) <form id="my_grid">

the only problem is that they are not filled in the next page

tested!

wdog avatar Apr 12 '17 07:04 wdog

👍 but i have more than page like that :((

nhoctanker avatar Apr 12 '17 08:04 nhoctanker

Hi!

  1. Why not place your inputs inside grid form?
  2. I don't recognize language on screen but suggest that there is filters for grid inside form. If I'm right, you can use Components/Filter.php. You can fully customize its appearance & filtering method (use callback in $filteringFunc & do anything you want with QueryBuilder).

Nayjest avatar Apr 12 '17 17:04 Nayjest

1 . beacasue i need create filter without gird not header / Footer of grid , 2. year that filters not inside form of gird. but i don't wan add to header or footer of gird . Beacasue my layout with two sections : filters, grid . and filter not on gird. Solutions

  1. Mabe i have must create layouts for gird and take filter inside
  2. replace name input filters if fiter not inside gird

nhoctanker avatar Apr 13 '17 03:04 nhoctanker

Mabe i have must create layouts for gird and take filter inside

You can create your own grid template based on https://github.com/Nayjest/Grids/blob/master/resources/views/default/grid.php and place anything you want inside grid form. Use GridConfig::setTemplate() to change template.

Nayjest avatar Apr 13 '17 10:04 Nayjest

Hi

I'm doing some test on builing a custom grid layout adding some new "filter fields", calling those filters with the syntax gridName[filters][filterName] I'm able to use them in all pages otherwise they will be removed when I change page.

How can I define a custom filter function in the Controller for those new inputs written in the view?

(we're getting closer to the solution :smile: )

wdog avatar Apr 13 '17 15:04 wdog

@wdog If you don't use Filter component, just adding HTML inputs to layout, You can read input (Input::get('grid_name.filters.some_field')) in Controller before constructing grid and apply your filters to instance of QueryBuilder that will be used with grid.

Nayjest avatar Apr 13 '17 16:04 Nayjest

I've just found a simple way to set default filter if they are not set, I don't know where to store this snippet so I put here in case someone will need it. ( maybe can I create a wiki page called snippets?)

$request = Request();

if ( !\Input::get( 'grid.filters.years-eq' ) ) {
    $request->request->add([ 'grid' => ['filters' => ['years-eq' =>  Carbon::now()->year]]]);
}

just call it before the grid creation

wdog avatar Dec 28 '17 08:12 wdog