FlexGrid RowCount

Posted by: lxrp-bst on 4 January 2021, 5:43 pm EST

    • Post Options:
    • Link

    Posted 4 January 2021, 5:43 pm EST

    Hi,

    I am using a standard c1-flex-grid with its items-source bound to a property of the view model in ASP.NET MVC.

    I have ```

    I want to be able to get the count of the displayed columns and display it in a control on the same page as the grid and have it update whenever the user changes the filters.
    Please advise how to do this?
  • Posted 5 January 2021, 2:37 pm EST

    Hi,

    The number of rows displayed in the FlexGrid can be get using the following code:

    
    var cnt=grid.rows.length;
    
    

    The bound column count can be get using the following code

    
    var colCnt = grid.columns.length;
    
    

    The above code works if no row/column’s visibility is changed respectively. In case the visible property is set to false for rows/columns, we need to iterate the rows/columns and check if the row/column is visible or not.

    Regards,

    Manish Gupta

  • Posted 6 January 2021, 8:57 am EST

    Thanks so much Manish.

    I would like to be able to get the row count AFTER a filter has been applied.

    Does that mean I will need to use the iterator approach to check the IsVisible property row by row?

    Also, assuming I need to use the iterator approach, I would like to add a handler to the FlexGridFilter.filterApplied event so I am updating the count after the filter has been applied. Using JavaScript, how to I access the filter belonging to the EventGrid to add the handler?

    I am unsure how to access the FlexGridFilter which is attached to the grid programatically; grid.filter and grid.collectionView.filter (which I have seen in other examples) both return undefined in my debugger (Chrome).

    Also please note I am using vanilla Java Script (with some JQuery) so no Angular or similar.

  • Posted 6 January 2021, 5:25 pm EST

    Hi,

    You need not iterate the rows until you have hide rows manually using the filterApplied event. Please refer to the following code snippet for reference:

    
    <script>
        function filterApplied(s, e) {
            console.log(s.grid.rows.length);
        }
    </script>
    <c1-flex-grid-filter id="filter" filter-applied="filterApplied"></c1-flex-grid-filter>
    
    

    Regards,

    Manish Gupta

  • Posted 11 January 2021, 5:47 pm EST

    Thanks Manish,

    The count worked as you suggested.

Need extra support?

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

Learn More

Forum Channels