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
15
How to apply multiple filters in worksheet with filterSettings().applyCustomFilter
posted

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

I am following

https://www.igniteui.com/javascript-excel-library/excel-worksheet-filtering

www.igniteui.com/.../javascript-excel-library-worksheet-level-filtering


And I ended up with code:

worksheet
.filterSettings().setRegion("C4:C29");      
worksheet.filterSettings().applyCustomFilter(0, new $.ig.excel.CustomFilterCondition($.ig.excel.ExcelComparisonOperator.equals, "New"));
worksheet.filterSettings().setRegion("D4:D29");         
worksheet.filterSettings().applyCustomFilter(0, new $.ig.excel.CustomFilterCondition($.ig.excel.ExcelComparisonOperator.equals, "New"));
worksheet.filterSettings().setRegion("E4:E29"); 
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?
Parents
No Data
Reply
  • 20
    Offline posted

    Hi,

    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().setRegion("A1:D29");
          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:

    sheet.filterSettings().setRegion("B1:C29");

    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.

    Filtering.zip

Children
No Data