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

Data Grid Remote Binding not working

2 Answers 103 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 19 Sep 2013, 06:02 PM
Maddening... Trying to utilize AJAX reads with a Kendo Grid.  I've done quite a few binding to data passed down from the model.  I copy the code straight from the KendoUI site and tweak to meet my demands:   
@(Html.Kendo().Grid<FaultReport2.Models.usp_CMC_TopIssues_Result>()
    .Name("grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.description).Title("Description");
        columns.Bound(p => p.responsible).Title("Responsibility");
        columns.Bound(p => p.charged_time).Title("Time");
        columns.Bound(p => p.responsible).Title("Responsible");
        columns.Bound(p => p.root_cause).Title("Root Cause");
        columns.Bound(p => p.counter_measure).Title("Countermeasure");
        columns.Bound(p => p.status).Title("Status");
    })
    .Pageable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(10)
        .Read(read => read
            .Action("cmcTopIssues", "FaultInfo", new { equipment_id = Model.area_id, start_date = Model.start_date })
        )
    )
)


Controller code for the read.Action():           
public ActionResult cmcTopIssues(int equipment_id, DateTime start_date)
        {
            var db = new Models.FAULTEntities1();            var top_issues = db.usp_CMC_TopIssues(equipment_id, start_date).ToList();            return Json(top_issues, JsonRequestBehavior.AllowGet);
        }

Does not work.  I verify that my cmcTopIssues method is being called and that the top_issues var is being filled.  It just does not populate the grid.When I switch over to local and pass the data down through the model, it works fine.

Any help would be appreciated.

2 Answers, 1 is accepted

Sort by
0
Steve
Top achievements
Rank 1
answered on 19 Sep 2013, 06:15 PM
Worth noting... In the same project I am filling Kendo Charts and Treeviews using an Ajax read.  Unless there is something environmental that is specific to the Grid, I think I have proper includes.
0
Steve
Top achievements
Rank 1
answered on 19 Sep 2013, 09:19 PM
Solution per "Slump" on StackOverflow.

public ActionResult cmcTopIssues([DataSourceRequest]DataSourceRequest request, int equipment_id, DateTime start_date)
{
    var db = new Models.FAULTEntities1();
 
    var top_issues = db.usp_CMC_TopIssues(equipment_id, start_date).AsEnumerable();
 
    return Json(top_issues.ToDataSourceResult(request));
}
Tags
Grid
Asked by
Steve
Top achievements
Rank 1
Answers by
Steve
Top achievements
Rank 1
Share this question
or