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

Posted by: lxrp-bst on 12 January 2021, 3:03 am EST

    • Post Options:
    • Link

    Posted 12 January 2021, 3:03 am 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?

  • Posted 13 January 2021, 3:05 am 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

  • Posted 20 January 2021, 12:26 am EST

    That worked perfectly, thanks!

  • Posted 18 February 2021, 3:56 am 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

  • Posted 19 February 2021, 1:57 am 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