kartik-v / yii2-grid

Enhanced GridView with various utilities for Yii Framework 2.0
http://demos.krajee.com/grid
Other
557 stars 303 forks source link

gridview in modal with pjax #1035

Closed strtob closed 2 years ago

strtob commented 2 years ago

Hi and thanks for this great extension!!!

I try to use gridview in a modal window with build-in pjax. Everything works, e.g. pagination - perfect!

Just the filter won't. If you use the filter, the whole page will reload (the request url doesn't inlcude "_pjax" parameter. Also if you use filterUrl and add the parameter here with '_pjax' => 'pjax-container-files' (in my chase this is the container id), the entire page will be reload and show me the grid view with the filtered values (i use renderajax in the controller). It seems, that pjax will be ignored.

Thanks for any ideas! Toby

strtob commented 2 years ago

I've found this code snippet. I don't know why, but this helps:

$(document).on('submit', 'form[data-pjax]', function (event) {
        $.pjax.submit(event, '#pjax-container-files',
                {
                    'push': false,
                    'replace': false,
                    'timeout': 5000,
                    'scrollTo': false,
                    'maxCacheLength': 0
                });
    });
strtob commented 2 years ago

to add: it's essential if you use pjax to give the gridview an id!