MVC
4 Controller code sample
//Use api Controller
//
GET api/use/
public
string Get(int id)
{
return "value";
}
@(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>