This is a migrated thread and some comments may be shown as answers.

Getting count of selected rows in grid

3 Answers 2087 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 12 Oct 2020, 07:05 PM

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. 

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Petar
Telerik team
answered on 14 Oct 2020, 10:00 AM

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).

0
David
Top achievements
Rank 1
answered on 16 Oct 2020, 12:21 PM
Thank you. That is what I was looking for.
0
Petar
Telerik team
answered on 20 Oct 2020, 06:42 AM

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/.

Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Petar
Telerik team
David
Top achievements
Rank 1
Share this question
or