Hello,
This is my first Kendo UI application. I am trying to create a simple project where it gets data from database and binds it to grid. There are about 350k records I am retrieving from the database. However, the data is not displayed/bind to the grid. I can see the data is being retrieved from database to the calling method but not sure why its unable to bind. I am not sure if its problem returning Json response or something else. Below is the code.
@{
ViewBag.Title = "Home Page";
}
<
div
class
=
"container-fluid"
>
<
div
class
=
"row"
>
<
div
class
=
"col-xs-18 col-md-12"
>
<
div
id
=
"grid"
></
div
>
</
div
>
</
div
>
</
div
>
<
script
>
$(document).ready(function () {
$(".textButton").kendoButton();
$("#grid").kendoGrid({
dataSource: {
type: "aspnetmvc-ajax",
transport: {
read: {
url: "Read"
}
},
schema: {
data: "Data",
model: {
id: "Id",
fields: {
"UserName": { type: "string" },
"Application": { type: "string" },
"Environment": { type: "string" },
"LoginTime": { type: "date" },
"IsSuccess": { type: "boolean" },
"IP": { type: "string" },
"Source": { type: "string" }
}
}
},
pageSize: 20,
serverPaging: true,
serverSorting: true,
serverSorting: true,
},
height: 550,
filterable: true,
sortable: true,
pageable: true,
columns: [{ field: "UserName",title: "User Name" },
{ field: "Application"},
{ field: "Environment"},
{ field: "LoginTime", title: "Login Time" },
{ field: "IsSuccess"},
{ field: "IP" },
{ field: "Source" }
]
});
});
</
script
>
public
ActionResult Read([DataSourceRequest]DataSourceRequest request)
{
IQueryable<Login> logins = db.Logins;
DataSourceResult result = logins.ToDataSourceResult(request, c =>
new
Models.Logins
{
Id = c.Id,
UserName = c.UserName,
Application = c.Application,
Environment = c.Environment,
LoginTime = c.LoginTime,
IsSuccess = c.IsSuccess,
IP = c.IP,
Source = c.Source
});
return
Json(result);
}
Thanks!