2

I want to append a parameter to the auto generated parameters of filtermodel in GridView
How do I add additional parameters?

5
  • 1
    Which url are you talking about ? . Can you share some code and specify where does this url appear in you code ? Commented Mar 15, 2016 at 7:48
  • for exam this is url that generate when we use filter in grid view localhost/reserve/hours-list?HourSearch%5Bgender%5D=men , but i want to append a parametr like "&date=2016/3/15" to endof this url ! Commented Mar 15, 2016 at 7:59
  • So everytime the filtering actions occur u need to pass additional parameters to your controller action right ?? . Commented Mar 15, 2016 at 8:39
  • Is this parameters view specific ?, i mean if these parameters are dynamic like todays date , we dont need to pass it to controler action. But can be directly used in controller Commented Mar 15, 2016 at 8:41
  • Thanks So Much ,filterUrl works ! Commented Mar 15, 2016 at 9:08

1 Answer 1

3

You can use 'filterUrl' property of GridView

In your GridView

<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'filterUrl' => ['YOUR_CONTROLLER_ACTIONID_HERE','date' => date('Y-m-d')],
    'columns' => [   
    ],
]); ?>

first parameter to 'filterUrl' is your action id. After that you can give your additional url parameters as key value pair

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.