Reputation: 303
Instead of using Pjax, which is giving me some problems, i would like to know how to apply the filter in a Yii2 GridView using javascript.
In the yii.gridView.js (loaded on yii2 every time you use the GridView widget) there are this lines inside var methods:
applyFilter: function () {
var $grid = $(this);
var settings = gridData[$grid.attr('id')].settings;
var data = {};
$.each($(settings.filterSelector).serializeArray(), function () {
if (!(this.name in data)) {
data[this.name] = [];
}
data[this.name].push(this.value);
}); ...
How do i call this function using javascript inside my page?
Upvotes: 3
Views: 1532
Reputation: 18021
Try
grid.yiiGridView("applyFilter");
where grid
is a GridView (i.e. element of .grid-view
class).
Upvotes: 5