Getting a reference to a flex-grid's flex-grid-filter

Posted by: lxrp-bst on 11 January 2021, 6:03 pm EST

  • Posted 11 January 2021, 6:03 pm EST

    I's using MVC Tag Helpers to setup a c1-flex-grid and associated c1-flex-grid-filter. It works fine, but when I want to reference the filter in java script (for example to add a handler) I cant figure out how to do it.

     
    var theGrid = wijmo.Control.getControl('#ff');
    theGrid.filter //undefined
    theGrid.collectionView.filter //undefined


    I've seen theGrid.filter and theGrid.collectionView.filter used in some examples but they don't work for me.
    Most other examples generate both the grid and the filter in js using wijmo, but because I am using the ASP tag helpers this isn't an option.

    I know I can use the event binding properties in the tag helpers (e.g. filter-changing) but I am sure there are plenty of situations where I need to get a direct reference to filter, is this possible in java script?

  • Marked as Answer

    Replied 12 January 2021, 6:05 pm EST

    Hi,
    You may get the FlexGridFilter reference in JS code using the following code snippet:
     <c1-flex-grid auto-generate-columns="true" is-read-only="true" height="500px" id="flexgrid1">
    ....
    <c1-flex-grid-filter id="filter" default-filter-type="Both" filter-changing="filterChanging" filter-applied="filterApplied"></c1-flex-grid-filter>
    </c1-flex-grid>
    <script>
    c1.documentReady(function (e) {
    var grid = wijmo.Control.getControl("#flexgrid1");
    filter = c1.getExtender(grid, "filter");
    })
    </script>

    Regards,
    Manish Gupta
  • Replied 19 January 2021, 3:26 pm EST

    That worked perfectly, thanks!
  • Replied 17 February 2021, 6:56 pm EST

    Has this changed in version 3.0.20203.297? It was previously working fine but when I upgraded its stopped working, GetExtender doesnt seem to be working

    var theFilter = c1.getExtender(theGrid, "filter");
    theFilter.filterApplied.addHandler(filterAppliedFunction);


    jquery.js:3850 Uncaught TypeError: Cannot read property 'filterApplied' of null
  • Replied 18 February 2021, 4:57 pm EST

    Hi,
    We are sorry, we are unable to replicate the issue at our end. Please refer to the attached sample for reference.
    In your project, please make sure the 'theGrid' variable has FlexGrid reference and the FlexGridFilter id is set to filter.

    Regards,
    Manish Gupta
    FlexGrid_filter.zip
Need extra support?

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

Learn More

Forum Channels