GridView Filter inside modal Problem

Hello everyone, I am rendering a gridview with filters inside a modal but each time I apply the filter it reloads the entire page. (Inside Bootstrap Modal)

Note: This is an Internet Explorer issue - gridview works well with chrome, will still test firefox and safari

I think this is related to yii2 issue no. 5958 on github but still with no answer until now.

I got this to work via adding input fields instead of using the standard grid filters and using js and ajax calls that I wrote on input change to render the grid and update dom element container (div).

It works but is definitely far way from being easy to develop especially if you have a number of fields u need to filter data based on and it doesn’t utilise the grid view filters that are already created. So I don’t see why we should reinvent the wheel when the gridview is supposed to do this already

Anyone managed to get filters of grid view to work inside Modal through the standard gridview filters? I mean without having to add input fields manually and writting custom js functions on change of input fileds…

Thanks for sharing your experiences.

Best Regards,

Mahmood

Incase someone faces this issue - Here are my findings and a solution that worked for me:

[b]General Finding:

[/b]PJAX works fine for refreshing the grid if the grid is loaded on the same page initially(not nested in another view called by ajax), however Filters don’t trigger pjax behavior though and refreshes the entire page which is definitely not something you want to do especially if you have your grid rendered in a bootstrap modal.

Solution:

I rendered the base page and used ajax for grid loading to nest the grid view inside the modal view, only then pjax gets triggered on filtering - so only works in a nested view. I used the registerjs function on the first view inside the modal container to register a function with ajax call and fires it up on view onload and updates a div with the grid (the controller function called by ajax rendersAjax the (‘view’, [$dataProvider and $ModelSearch]). I clear the bootstrap modal content container on modal hide/close behavior.

If you found a better solution please share for the benefit of the community.

Best Regards,

Mahmood