kendo ui grid total row get total number of rows in a grid

kendo ui grid total row count

Hello everyone, I am going to share the code sample for 
"get total number of rows in a kendo ui grid".

Code sample for MVC 4 kendo Grid


@(Html.Kendo().Grid<PCX.Models.Use>()
    .Name("CallByCallUsage")
                    .Groupable()
                    .Sortable()
                    .Pageable()
                    .Scrollable()
            .Columns(columns =>
            {
                columns.Bound(e => e.AParty_Subscriber).Title("A Party");
                columns.Bound(e => e.BParty);
                columns.Bound(e => e.Date_Time).Format("{0:dd-mm-yyyy / h:mm:ss}").Title("Date & Time");
                columns.Bound(e => e.NetworkID).Title("Network").ClientTemplate("#: getNetworkName(NetworkID) #");
                columns.Bound(e => e.CallType);
                columns.Bound(e => e.Location);
                columns.Bound(e => e.CallDirection);
                columns.Bound(e => e.Unit);
            })
            .DataSource(dataSource => dataSource
                .Ajax()
                .Model(model => model.Id(p => p.ID))
                .Read(read => read.Action("GetUsage", "Api/Use").Type(HttpVerbs.Get).Data("sendData"))
            )
    )

Code sample for JavaScript

<script type="text/javascript">
    $(document).ready(function () {
        totalNoOfRows();
        sendData();
    });

    function sendData() {
        return {
            TenantID: '@userSession.TenantID',
            CompanyID: '@userSession.CompanyID'
        };
    }

    function totalNoOfRows() {
        var kendoGrid = $("#CallByCallUsage").data("kendoGrid");

        //THis is for get the length of grid.
        var grdLength = kendoGrid.dataSource.view().length;
        console.log(grdLength);

        //This is for get total no of records.
        var grdTotal = kendoGrid.dataSource.total();
        console.log(grdTotal);
    }
</script>


ANIL SINGH

Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..
My Blogs - https://code-sample.com and https://code-sample.xyz
My Book1 - BEST SELLING ANGULAR BOOK (INCLUDING ALL VERSIONS 2, 4, 5, 6, 7)
My Book2 - ANGULAR 2 INTERVIEW QUESTIONS BOOK - Both Books are Available on WorldWide.

www.code-sample.com/. Powered by Blogger.