Get filter data GridView and make pdf

hi all.

I need to get data filtering a GridView to make a report. I do currently sending to view the searchModel used for filtering. i build button placing the parameters that the searchModel is in the url link to send as parameters to the action where do the pdf. but I’m not sure that’s the best way and I’m not happy about it XD but if it works. The code:


Html :: a ('Pdf' ['pdf', 'ModelSearch' => [

     'data1' => $ searchModel ['data1'],

     'data2' => $ searchModel ['data2'],

     'Data3' => $ searchModel ['Data3'],

]], ['Class' => 'btn btn-primary'])

Some might indicate me a way to do it more correct. or obvious way to not notice me XD

Thanks for your time.