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

How can i bind result from asp.net mvc Controller ActionResult

1 Answer 725 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Vijay
Top achievements
Rank 1
Vijay asked on 05 Jun 2012, 04:02 PM
I am try to bind data to a list view (http://demos.kendoui.com/web/listview/index.html) from result of asp.net mvc controller method.
What is the way we can attach the model data or Controller data to the kendo datasource?

Below code does not work.

--MVC Controller Method returning Products results set.
public ActionResult GetProducts()
{
----------
  return Json(Products, JsonRequestBehavior.AllowGet);
}

--Javascript to bind datasource
var dataSource = new kendo.data.DataSource({
                    transport: {
                        read: {
                            url: ('@Url.Action("GetProducts")'),
                            dataType: "jsonp"
                        }
                    },
                    pageSize: 12
                });
// Model View @model IEnumerable<Models.Product>
@{
    ViewBag.Title = "Index";
}

1 Answer, 1 is accepted

Sort by
0
Accepted
nachid
Top achievements
Rank 1
answered on 05 Jun 2012, 09:38 PM
your action is returning JSON and not JSONP
return Json(Products, JsonRequestBehavior.AllowGet);
You should use json as datatype in your datasource
Tags
Data Source
Asked by
Vijay
Top achievements
Rank 1
Answers by
nachid
Top achievements
Rank 1
Share this question
or