This is a migrated thread and some comments may be shown as answers.

Grid Issues

2 Answers 47 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nick
Top achievements
Rank 1
Nick asked on 12 Oct 2016, 09:04 PM

 

 

I can't seem to figure out why my grid doesn't show data. Here's the Contoller code:

public JsonResult PopulateGrid()
{
var x = (from n in dbContext1.GetOrders("Melody Devoe") select n);
List<string> items = new List<string>();
foreach (var item in x)
{
items.Add(item.ToString());
}

return Json(items.ToList(), JsonRequestBehavior.AllowGet);

}

 

Here's the cshtml:

<div class="a">
@(Html.Kendo().Grid<CentralBilling.Models.GetOrders_Result>()
.Name("gridRater")
.DataSource(datasource => datasource
.Ajax()
.Read(read => read.Action("PopulateGrid", "Home")))
.Columns(columns =>
{
columns.Bound(o => o.Order_Number);
//columns.Bound(o => o.ActDate);
//columns.Bound(o => o.Agent_Role);
//columns.Bound(o => o.aom_shipment_type);
//columns.Bound(o => o.Delay);
//columns.Bound(o => o.DeadlineDist);
//columns.Bound(o => o.DistStatus);
//columns.Bound(o => o.SubmitDate);
//columns.Bound(o => o.LastAct);
//columns.Bound(o => o.LastComment);
})
.Sortable()
.Scrollable()
.Filterable()
.Selectable()
)
</div>

I'm using a stored procedure pulled in through the Model. At first I had trouble with the proc parameter so I hardcoded one and still no luck. This is driving me crazy! Thanks in advance

2 Answers, 1 is accepted

Sort by
0
Nick
Top achievements
Rank 1
answered on 12 Oct 2016, 09:12 PM
Here's a photo of my model
0
Marin
Telerik team
answered on 14 Oct 2016, 08:43 AM
Hi,

When using .Ajax() binding for the grid you have to use the ToDataSourceResult() method in the controller's Read method as shown in this help article:
http://docs.telerik.com/kendo-ui/aspnet-mvc/helpers/grid/binding/ajax-binding#configuration
and this online demo:
http://demos.telerik.com/aspnet-mvc/grid/index

I hope this helps. Let me know if you have any other questions.

Regards,
Marin
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Nick
Top achievements
Rank 1
Answers by
Nick
Top achievements
Rank 1
Marin
Telerik team
Share this question
or