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

Does the Grid's datasource really need JSon format when I binding the property of a model?

3 Answers 78 Views
Grid
This is a migrated thread and some comments may be shown as answers.
PEIYANG
Top achievements
Rank 1
PEIYANG asked on 18 Apr 2013, 12:27 PM
Does the Grid's datasource  really need JSon format when I binding the property of a model called student?
Can I use viewresult(list<student>)? I find all the example are return jsonresult.

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 20 Apr 2013, 05:06 PM
Hello,

In MVC, An action method responds to user input by performing work and returning
an action result. An action result represents a command that the
framework will perform on behalf of the action method. The ActionResult class is the base class for action results.

The following types derive from ActionResult:

ContentResult
EmptyResult
FileResult
HttpUnauthorizedResult
JavaScriptResult
JsonResult
RedirectResult
RedirectToRouteResult
ViewResultBase

As per above JsonResult is better option to return List from controller to View.

Note : if possible then can you please elaborate scenario (explain why you do not need to use jsonResult) ?
by using this class "using Kendo.Mvc.Extensions;"  you can easily convert your list to jasonResult.

public ActionResult Grid_Read([DataSourceRequest]DataSourceRequest request)
        {
            var dataItem =new List<Students>(); / /Your datasource comes here
            return Json(dataItem.ToDataSourceResult(request));
        }


Thanks,
Jayesh Goyani
0
PEIYANG
Top achievements
Rank 1
answered on 20 Apr 2013, 05:22 PM
return view instead of jsonresult I can easily get the property of student in the view page
0
Jayesh Goyani
Top achievements
Rank 2
answered on 22 Apr 2013, 08:15 AM
Hello,

We have to return the collection of Data (Like : List/DataTable/.....etc). 

Can you please elaborate your scenario, so we can try to achieve your scenario another way?

Thanks,
Jayesh Goyani
Tags
Grid
Asked by
PEIYANG
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
PEIYANG
Top achievements
Rank 1
Share this question
or