Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
How to apply multiple filters in worksheet with filterSettings().applyCustomFilter

I want to add filter menu to all of the columns I have in my worksheet generated with JavaScript Excel.

I am following

And I ended up with code:

worksheet.filterSettings().applyCustomFilter(0, new $.ig.excel.CustomFilterCondition($.ig.excel.ExcelComparisonOperator.equals, "New"));
worksheet.filterSettings().applyCustomFilter(0, new $.ig.excel.CustomFilterCondition($.ig.excel.ExcelComparisonOperator.equals, "New"));
worksheet.filterSettings().applyCustomFilter(0, new $.ig.excel.CustomFilterCondition($.ig.excel.ExcelComparisonOperator.equals, "New"));

But unfortunatelly only LAST applied filter stays in it's place. Any filter before is not applied and shown.

Is there any way to add more than one filter to the worksheet?
No Data
  • 280
    Offline posted


    Thank you for contacting us!

    The behavior that occurs on your side is caused because of setting numerous regions for filtering which sets only the last one to be applied.

    The setRegion  has to be the area where you want to have filtering. And with the applyCustomFilter method you set the columns which you want to be filtered.

    For example:

          sheet.filterSettings().applyCustomFilter(0, new $.ig.excel.CustomFilterCondition($.ig.excel.ExcelComparisonOperator.greaterThan, 3224));
          sheet.filterSettings().applyCustomFilter(1, new $.ig.excel.CustomFilterCondition($.ig.excel.ExcelComparisonOperator.contains, "a"));
          sheet.filterSettings().applyCustomFilter(2, new $.ig.excel.CustomFilterCondition($.ig.excel.ExcelComparisonOperator.equals, "New"));
          sheet.filterSettings().applyCustomFilter(3, new $.ig.excel.CustomFilterCondition($.ig.excel.ExcelComparisonOperator.equals, "a"));

    This way you set all the columns to have filtering.

    Keep in mind that the applyCustomFilter method takes the relative index of the columns in the region for filtering.

    This means that if you have region:


    The columns indexes will be 0 and 1.

          sheet.filterSettings().applyCustomFilter(0, new $.ig.excel.CustomFilterCondition($.ig.excel.ExcelComparisonOperator.contains, "a"));
          sheet.filterSettings().applyCustomFilter(1, new $.ig.excel.CustomFilterCondition($.ig.excel.ExcelComparisonOperator.equals, "New"));

    I made a sample code based on your requirement, please take a look at it and let me know if you have any further questions.

No Data