[Wijmo-pureJs] Open Filter on keypress

Posted by: handerson on 29 July 2019, 9:38 pm EST

    • Post Options:
    • Link

    Posted 29 July 2019, 9:38 pm EST

    Hi, is it possible to open the filter for a specific column on keypress like ctrl+f??

    I have searched the forum but wasn’t lucky :confused:

    Best regards

    Helge

  • Posted 29 July 2019, 10:28 pm EST

    Ok. Found a solution.

    window.addEventListener(‘keydown’, e => {

    if (e.keyCode === 114 || (e.ctrlKey && e.keyCode === 70)) {

    e.preventDefault();

    document.getElementsByClassName(‘wj-elem-filter’)[0].click();

    document.getElementsByClassName(‘wj-dropdown-panel wj-control wj-content wj-columnfiltereditor wj-state-empty’)[0].classList.add(‘wj-state-focused’);

    document.getElementsByClassName(‘wj-dropdown-panel wj-control wj-content wj-columnfiltereditor wj-state-empty wj-state-focused’)[0].classList.remove(‘wj-state-empty’);

    }

    });

    But is there a nicer way of getting the job done?

  • Posted 29 July 2019, 11:46 pm EST

    Hi Helge,

    You approach regarding handling the keydown event is correct but you may simply call the editColumnFilter method of FlexGridFilter class to open the column filter. Refer to the code snippet and sample below:

    document.addEventListener('keydown', e => {
      if(e.ctrlKey && (e.key == 'f' || e.key == 'F')) {
        e.preventDefault();
        gridFilter.editColumnFilter(grid.columns.getColumn('country'));
      }
    })
    

    https://stackblitz.com/edit/js-mcmb7m

    Regards,

    Ashwin

Need extra support?

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

Learn More

Forum Channels