3

I've a kendo grid some thing like this

$("#HoleGrid").kendoGrid({ ... });

how can I find out how many rows are in grid??

Ahmed Zamil
  • 238
  • 2
  • 6
  • 17

2 Answers2

6

Try using the following. It should work...

$("#HoleGrid").data("kendoGrid").dataSource.data().length

or as #Quinton Bernhardt

$("#HoleGrid").data("kendoGrid").dataSource.total()
Mahib
  • 3,977
  • 5
  • 53
  • 62
  • How do we set the total row count? for setting the data we can do something like this `$("#grid").data("kendoGrid").dataSource.data(ARRAY_OF_DATA);` But this does not allows us to set row count – SharpCoder Feb 23 '16 at 17:32
  • I normally do a grid refresh after each row update. – Mahib Feb 23 '16 at 18:09
  • I am making a ajax call on page load. the autoBind property for the page is setup as false. when i get response, it has two property. `data` & `rowCount`. i assign data using `$("#grid").data("kendoGrid").dataSource.data(response.data);`. how do i set the `rowCount` to enable paging. – SharpCoder Feb 23 '16 at 18:12
  • Need to check before I can tell. But in your scenario I normally set the page size on js grid initialization and when I get data kendo normally do the paging itself. Are you talking about the serverside paging?? – Mahib Feb 23 '16 at 18:17
  • You can check this as well http://stackoverflow.com/questions/16901798/get-record-count-in-kendo-grid-after-datasource-read – Mahib Feb 23 '16 at 18:21
  • thank you for quick reply. my scenario is different. i only send those records i want to show on grid. when user page, i want to go to the server, get next set of records and then update the grid and total rowCount – SharpCoder Feb 23 '16 at 18:27
  • Check this one if helps http://jsfiddle.net/rusev/Lnkug/ – Mahib Feb 23 '16 at 18:35
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/104325/discussion-between-mahib-and-sharpcoder). – Mahib Feb 23 '16 at 18:37
  • I cannot chat. Its blocked in my organization – SharpCoder Feb 23 '16 at 18:39
  • Also check in the api ref >> http://docs.telerik.com/KENDO-UI/api/javascript/ui/grid#fields-pager – Mahib Feb 23 '16 at 18:40
4
    var grid = $("#HoleGrid").data("kendoGrid");
    var count = grid.dataSource.total();
Quinton Bernhardt
  • 4,773
  • 19
  • 28