Getting row count after filtering

Originally Posted 7 February 2013, 11:27 am EST

  • Originally Posted 7 February 2013, 11:27 am EST

    I'm currently getting a row count using:
    $("#element").wijgrid("data").length which works great until I use a filtering option. It still shows the full count instead of the filtered count. How can I get the filtered count?

    Thanks in advance.
  • Reply

    Hi Abdias,

    Thank you very much for your reply. Your method works well, but it only gives the count of filtered items displayed on the first page of results. If there are 13 rows after filtering and the pagesize is set to 10, your method will only return 10.

    Is the filtered result set not stored anywhere?

    Thanks again.
  • Reply

    Hi,

    You're right. It only gives the count of the filtered items on the first page and there doesn't seem to be a way to get the set of all filtered rows. You can post this as a feature in wijgrid on our uservoice page : http://wijmo.uservoice.com/
    Other users can also vote it so that it gets incorporated on priority.

    Regards
    Abdias
  • Reply

    Hi,

    As a workaround for this, what you can do is set the allowPaging option to false, count the rows and then set the allowPaging to true again in the filtered event :

    filtered: function (e, args) {
    var grid = $(this);
    grid.wijgrid({ allowPaging: false });

    var rows = this.rows;
    var count = 0;
    $.each(rows, function (index, elem) {
    if ($(elem).hasClass("wijmo-wijgrid-datarow")) {
    count++;
    }
    });

    grid.wijgrid({ allowPaging: true });
    alert(count);
    }


    Regards
    Abdias
  • Reply

    Hi Jdunkel,

    There's no native way to get the filtered rows. You could handle the filtered event of wijgrid and get the filtered rows in the following way :

    filtered: function (e, args) {
    var rows = this.rows;
    var count = 0;
    $.each(rows, function (index, elem) {
    if ($(elem).hasClass("wijmo-wijgrid-datarow")) {
    count++;
    }
    });
    }


    Hope if helps

    Regards
    Abdias
  • Marked as Answer

    Reply

    Thank you! This workaround will do the job while adding this as a new feature is decided :)
Need extra support?

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

Learn More

Forum Channels