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

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.