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

Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
My Blogs - http://www.code-sample.com and http://www.code-sample.xyz
My Books - Buy Books Online at Best Prices

You Might Also Like
Post a Comment
www.code-sample.com/. Powered by Blogger.