Hi,
I've created a simple MVC 5 project with a Kendo grid to display a few records from a remote server. When i run the application, the kendo grid appears but displays no records.
I checked Fiddler and found no errors or circular references. Furthermore, the JSON output shows the correct data in it but its simply not displaying in the grid. Here is the grid and controller code:
Controller:
Could you please help me figure out what the issue is with the data not displaying in the grid?
Thanks, Shuja
I've created a simple MVC 5 project with a Kendo grid to display a few records from a remote server. When i run the application, the kendo grid appears but displays no records.
I checked Fiddler and found no errors or circular references. Furthermore, the JSON output shows the correct data in it but its simply not displaying in the grid. Here is the grid and controller code:
<
div
style
=
"width:830px;font-size:x-small; padding-top:40px;"
>
@(Html.Kendo().Grid<
SystemsFormsMVC.Models.vMyForm
>()
.Name("Grid1")
.Columns(columns=>
{
columns.Bound(o => o.Id);
columns.Bound(o => o.SystemName);
columns.Bound(o => o.FormType);
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.Read(read => read.Action("GetMyForms", "Home"))
)
.Pageable()
.Navigatable()
.Sortable()
.Filterable()
)
</
div
>
Controller:
public
ActionResult GetMyForms([DataSourceRequest] DataSourceRequest request)
{
var query = _repository.GetMyForms(GetCurrentUserName());
query = query.OrderBy(s => s.RequestDate);
return
Json(query, JsonRequestBehavior.AllowGet);
}
public
IQueryable<vMyForm> GetMyForms(
string
UserName)
{
SystemsFormsDataContext db =
new
SystemsFormsDataContext();
IQueryable<vMyForm> query;
Int32 UserId = GetCurrentUserId(UserName);
try
{
query = (from s
in
db.vMyForms
where s.UserId == UserId
select s);
}
catch
(Exception ex)
{
query = (from s
in
db.vMyForms
where s.UserId == 0
select s);
}
return
query;
}
Could you please help me figure out what the issue is with the data not displaying in the grid?
Thanks, Shuja