Kendo ui grid record length count

Kendo ui grid record length count

MVC 4 Controller code sample

 //Use api Controller
// GET api/use/
public string Get(int id)
{
    return "value";
}

 Kendo MVC4 Grid code sample

@(Html.Kendo().Grid<PCX.Models.UsageByPricing>()
    .Name("kndoGridId")
    .Sortable()
    .Pageable()
    .Scrollable()
    .Columns(columns =>
    {
        columns.Bound(e => e.Product).Title("Product");
        columns.Bound(e => e.UsageIncluded).Title("Usage Included");
        columns.Bound(e => e.UsageIncludedTypeID).Title("Usage Included Type").ClientTemplate("#: getUsageIncludedType(UsageIncludedTypeID) #");
        columns.Bound(e => e.NetworkID).Title("Network").ClientTemplate("#: getNetworkName(NetworkID) #");
        columns.Bound(e => e.UsageMade);
    })
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("GetUsageByPricing", "Api/Use").Type(HttpVerbs.Get).Data("sendData"))
    )
)

JavaScript Code sample

<script type="text/javascript">
var kendoGrid = $("#kndoGridId").data("kendoGrid");

var msg = "<div class='clr_15'></div><div class='alert grid-no-record'>No Record found</div>";

if (kendoGrid !== undefined && kendoGrid !== null) {
    kendoGrid.bind("dataBound", function (e) {
        if (e.sender.dataSource.view().length === 0) {
            console.log(e.sender.dataSource.view().length);
            e.sender.table.closest(".k-grid-content").css({ "overflow-y": "scroll;" });
            e.sender.table.closest(".k-grid-content").replaceWith(msg)
        }
    });
}

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

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