2

I have two jqxgrids that are both sourced from the same place and use the same dataAdapter to get the data. One grid has columns that are filterable. I can't figure out how to force the second grid to re-filter automatically when user enters some filter text in the first. Has anyone done that or it is even possible without having to create custom filters?

Alexey Gerasimov
  • 2,131
  • 13
  • 17

2 Answers2

1

Using the 'getfilterinformation', you can get the jqxGrid's filters, conditions and values. getfilterinformation returns an array of filters. Each item in the array has the following fields:

  • filter - that's the column's filter. You can think about the filter as a group of filters, because a column may have more than 1 applied filters. By calling filter.getfilters(), you can get all filters applied to a column. Each filter in the filter group, has {value, condition, operator and type}, where value is the filter's value, condition is ex: "Contains", operator could be "and" or "or" and the type represents the filter's type (stringfilter, datefilter, etc.).

  • filter column's datafield.

Then, you can apply the filter to a Grid instance as shown in this sample: customfiltering.htm

scripto
  • 2,297
  • 1
  • 14
  • 13
  • thanks. I can definitely do that, and actually did do it. Putting code in the filter function on the first grid and then applying filters to others was pretty straightforward. I was curious if there's some automated magic that can be make it happen by itself. If nobody comes up with that soon, I'll accept your answer. – Alexey Gerasimov Dec 04 '12 at 13:25
0

You can bind a method to the first grid's filter event. As specified in the API:

$("#jqxGrid").on("filter", function (event) {
  var filterinfo = $("#jqxgrid").jqxGrid('getfilterinformation');
  // then iterate through the filters applied to the 1st grid, and
  // write the appropriate codes to apply the same filters to the 2nd grid
});

HTH :)