Getting count of selected rows in grid

4 posts, 0 answers
  1. David
    David avatar
    2 posts
    Member since:
    Oct 2020

    Posted 12 Oct 2020 Link to this post

    Hello Everyone,

    I am relatively new to Kendo. I have a question is it possible to get the count of selected rows in a column and added it to the paging bar? If so how? I have highlighted the area in a screenshot. 

     

     

     

     

  2. Petar
    Admin
    Petar avatar
    511 posts

    Posted 14 Oct 2020 Link to this post

    Hi David,

    Here is an example of how targeted functionality can be implemented. To realize it the dataBound and change events of the Grid are used. 

    Once the dataBound event is triggered, the following code is executed. It adds a DOM element after the pager of the Grid. 

    var pagerElement = this.pager.element;
    if (!pagerElement.find(".myCustomElement").length) {
          pagerElement
             .append('<div class="myCustomElement">No rows are selected</div>');
    }

    Once a user selects a row in the Grid, the below code is executed. 

    var rows = e.sender.select();
    if(rows.length !== 0){
        $(".myCustomElement").text("Number of selected elements: " + rows.length)
    }
    else {
        $(".myCustomElement").text("No rows are selected")
    }

    Based on the code in yellow, the text inside our custom element is changed. The code in green uses the select method of the Grid to get the currently selected rows. 

    I hope the example demonstrates what you want to implement.

    Regards,
    Petar
    Progress Telerik

    Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

  3. David
    David avatar
    2 posts
    Member since:
    Oct 2020

    Posted 16 Oct 2020 in reply to Petar Link to this post

    Thank you. That is what I was looking for.
  4. Petar
    Admin
    Petar avatar
    511 posts

    Posted 20 Oct 2020 Link to this post

    You are welcome, David!

     

    Regards,
    Petar
    Progress Telerik

    Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Back to Top