How update Yii2 GridView from JS

Hello, I need update GridView on click action. Clicked element is out GridView form. So I tried make something like that

$.pjax.reload({container: "#products_ajax_container", data: {"ProductsSearch[store_id]": store_id, "ProductsSearch[category_id]}": category_id}}); 

it working but I getting duplicates always when click action was called

ProductsSearch[category_id] = 4

ProductsSearch[category_id] = 15

ProductsSearch[category_id] = 7

ProductsSearch[store_id] = 1

ProductsSearch[store_id] = 1

ProductsSearch[store_id] = 1

and this parameters always adding and didn’t replace

How I can remove duplicates? Thanks.

Perhaps the bracket "}" causes the problem?


Oh, sorry, that was just typing mistake there. My problem is still here, and I need fix this because when I click too much page has reflashing? and it’s not good

Any help? How I can send params manually? :mellow:

if you have a search form and grid that is wrapped in pjax you need to set the ‘action’ url manually on the form (i’d use Url::to([])) on the search form or it will keep appending the GET params instead of updating to the new one(s).

to send the params manually in the url or in the controller you need to change your searchModel portion that loads the params like

if (isset($_GET['ProductSearch']) && !($this->load($params) && $this->validate())) {

            return $dataProvider;


You can now send the values in the url or controller like

  $searchModel = new ProductSearch(['category_id' => $id]);

make sure you have rules and filters set in the searchModel as well. [size="2"]Hopefully that helps.[/size]

Thanks, that helped. But have one problem now, how send what user selecten in GridView with my extra data?

Can I use



are you trying to use a checkbox column and get which rows are checked?

no, I don’t use checkbox