Changing default filter no longer works

Posted by: stefan.brenner.a on 13 April 2018, 8:25 am EST

    • Post Options:
    • Link

    Posted 13 April 2018, 8:25 am EST

    Hi,

    I once asked how to change the default behavior of the FlexGrid filter. I didn’t want the default behavior of it showing the value filter but instead did want it to start in the conditions filter with the Contains filter as a default. I got some helpful sample code looking like this:

    this.gridFilter.filterChanging.addHandler((gridFilter: wjGridFilter.FlexGridFilter, e: any) => {

    var cf = gridFilter.getColumnFilter(e.col);

    if (!cf.valueFilter.isActive && cf.conditionFilter.condition1.operator == null) {

    cf.filterType = wjGridFilter.FilterType.Condition;

    cf.conditionFilter.condition1.operator = wjGridFilter.Operator.CT;

    }

    });

    This has worked fine with version 2017 of the Wijmo controls but since I updated to 5.20181.436 I’m running into problems. The code still executes but when the filter dialog is first shown it shows the value filter. Only when it is opened a second time will the changes have been applied.

    Can you please help me either with a bugfix or with some sample code on how to achieve the wanted behavior in the current version.

    Thanks and best regards.

  • Posted 16 April 2018, 4:23 am EST

    For the simplicity FlexGridFilter now provides defaultFilter property to set the filter type.

    Please use it to set default filter types.

    //refer to following code snippet

    
    this.gridFilter.defaultFilterType=wjcGridFilter.FilterType.Condition;
    
    

    Here is an example of the same:-

    https://stackblitz.com/edit/angular-lfziyi?file=app%2Fapp.component.ts

  • Posted 20 April 2018, 5:07 am EST

    Hi,

    thanks for the reply. This solves a part of the problem and would definitely be a nicer way of handling the default behavior if I can get it to work completely. Do you also have an option to set the default operator of the conditions filter to the Contains operator? Otherwise I’d still need some help to make this work as before.

    Thanks and best regards.

  • Posted 23 April 2018, 7:09 am EST

    Hi,

    You can easily customize filter options shown by accessing cultures object.

    Please refer to the following example:-

    https://stackblitz.com/edit/angular-aekpfs?file=app/app.component.ts

    A list of available operators can be found here:- http://demos.wijmo.com/5/Angular/WijmoHelp/WijmoHelp/topic/wijmo.grid.filter.Operator.Enum.html

    ~Manish

  • Posted 24 April 2018, 4:34 am EST

    Hi,

    I wanted to have the Contains filter on every column as a default but I managed with both your samples by iterating over each column when the collection is set. This seems to work fine - so the code to set the column filter has remained the same, just the time when to do it had to be changed with the update to the current version. So thanks for your support.

    BTW can you also see that the name of the poster of this thread has been changed to chris.karkowsky? I started the topic but this is not my user name - kind of strange.

    Thanks and best regards.

  • Posted 24 April 2018, 7:57 am EST

    Hi Stefan,

    Apologies. I’m not sure how much you enjoyed being me, but I have reverted your username back to the way it should be :).

    Chris

  • Posted 6 December 2024, 1:35 am EST

    Hi Team

    I am facing the same issue in version 5.20241.19

    I am updating the filterType of each column on Flexgrid initialized event. But for some reason Flexgrid is overriding my changes to the filterType with the defaultFilterType after the initialized event callback function has executed.

    If I do the same inside a setTimeout of 1000 miliseconds, then it works.

    Please let me know the event in which we can update filterType ?

  • Posted 6 December 2024, 6:35 am EST

    Hi Abhijeet,

    Assuming that you are using Angular framework in your application, we tested the behavior you described but did not face any issues. However, it might be possible that the flexgrid filter is getting initialized at a later stage, so you can try the ‘initialized’ event of the FlexGridFilter, instead of FlexGrid to update the filter type for columns.

    Here’s a sample for your reference - https://jscodemine.mescius.io/share/voWv5ebGnEaPtwHGavRs5g/

    In case, you still face this issue, please modify the above sample to replicate the issue and share it with us, so that we can have a better understanding of the issue and assist you accordingly.

    Regards

  • Posted 16 December 2024, 8:29 am EST

    Your demo works as expected, but when I try the same in my project, it doesn’t work

    I have to put the code in 1000 millisecond timeout and then it works

  • Posted 17 December 2024, 2:27 am EST

    Hi Abhijeet,

    We are not exactly sure about the implementation on your side, could you please share a small sample in which the issue can be replicated so that we can investigate the issue on our end and assist you accordingly?

    You can also modify the sample we shared in our previous post, to replicate the issue and share it with us.

    Regards

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels