Skip to content

Infragistics Community Forum / Web / Ignite UI for jQuery / Event after grid filtering to retrieve the number of filtered rows

Event after grid filtering to retrieve the number of filtered rows

New Discussion
Michael Mangelschots
Michael Mangelschots asked on Aug 8, 2014 12:20 PM

Hello,

We would like to display the filtered rows count outside of the grid. Currently this is displayed in the class ui-iggrid-results at the bottom of the grid. 
Is there some kind of event we can handle and is there a way in that event to get the number of "filtered" rows? We would then be able to update a label outside of the grid with the new number.

Kind regards,

Michael

Sign In to post a reply

Replies

  • 0
    Stamen Stoychev
    Stamen Stoychev answered on Aug 7, 2014 8:51 AM

    Hello Michael,

    The exact solution will depend heavily on whether or not you are using Paging in your application and in which mode Filtering and Paging operate (local or remote). I am attaching a sample for the basic scenario with just Filtering enabled in local mode. When this is the case you can make Filtering not display its summary with the filterSummaryAlwaysVisible option set to false. The number of filtered rows will be the same as the length of the grid’s data source data view. The whole Filtering options object will look like this:

    {
        name: "Filtering",
        filterSummaryAlwaysVisible: false,
        dataFiltered: function (evt, ui) {
             $("#filteredRowsLabel").text(ui.owner.grid.dataSource.dataView().length);
        }
    }

     

    Please, let me know if your scenario involves Paging so I can prepare a more suitable sample!

    Thank you for using Infragistics forums!

    Best regards,

    Stamen Stoychev

     

    • 0
      Michael Mangelschots
      Michael Mangelschots answered on Aug 7, 2014 9:45 AM

      Hello Stamen,

      Thanks for the quick reply!

      Yes, our scenario will involve Paging. Won't the same "dataFiltered" event nog be usefull with paging ?

      Best regards,

      Michael

      • 0
        Stamen Stoychev
        Stamen Stoychev answered on Aug 7, 2014 12:56 PM

        Hello Michael,

        The event is still perfectly usable, however, the data view is a combination of the filtering expressions and the paging settings. Its size will never exceed the page size while you might have more filtered records. In this case a stable way of obtaining how many records passed the filter is using an internal collection of the data source called _filteredData. The handler in my sample will then look like this:

        dataFiltered: function (evt, ui) {    $(“#filteredRowsLabel”).text(ui.owner.grid.dataSource._filteredData.length); }

        If you don’t want to deal with non-public members I can propose another way. While Filtering and Paging share the same information label and you could completely remove it by setting filterSummaryAlwaysVisible: false for Filtering and showPagerRecordsLabel: false for Paging, instead you can simply hide it with CSS then use its contents to populate your own label. I am attaching a sample demonstrating this approach.

        Please, let me know if you have any other questions and/or concerns!

        Best regards,

        Stamen Stoychev

        Attachments:
      • 0
        Michael Mangelschots
        Michael Mangelschots answered on Aug 8, 2014 8:19 AM

        Thanks a lot for the information Stamen.

        Looks good, I'll try it asap.

        Michael

      • 0
        Stamen Stoychev
        Stamen Stoychev answered on Aug 8, 2014 12:20 PM

        Hello Michael,

        I am glad I was able to assist you! Good luck with your project!

        Please, don't hesitate to contact me if you have any other questions and/or concerns.

        Best regards,

        Stamen Stoychev

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Michael Mangelschots
Favorites
0
Replies
5
Created On
Aug 08, 2014
Last Post
12 years, 1 month ago

Suggested Discussions

Tags

Created on

Aug 8, 2014 12:20 PM

Last activity on

Aug 8, 2014 12:20 PM