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

Passing Object over Read Action

3 Answers 310 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 28 May 2014, 09:35 PM
I am having an issue with passing additional parameters over a read function.

@(Html.Kendo().Grid<Wue.Web.Employee.Model.Models.DocumentLine>()
        .Name("documentLinesGrid" + @Model.Document.DocumentNumber + "lines")
        .Columns(col => {
                col.Bound(c => c.VendorPartNumber).Title("Vendor Part Num");
                col.Bound(c => c.Quantity);
                col.Bound(c => c.Price);
            }
        )
        .Scrollable()
        .DataSource(ds => ds
            .Ajax()
            .Read(readLineData => readLineData.Action("GetLineData", "Document", new { currentDoc = Model.Document }))
        )
        .ColumnMenu()
    )


On the Controller I have this as my action method:

public ActionResult GetLineData([DataSourceRequest] DataSourceRequest request, Document currentDoc) { }

The issue is that the data that is being sent is always null. I have tried to change the type to a string and passing currentDoc = "123" and having the action method accept a string currentDoc and that seems to work. Why will an object not pass through?

Note: I have also attempted to use js to send the information by using the .Data(functionName) and then in js using return { Html.Raw(Json.Encode(Model.Document)) but that returns null as well. Please help as I cannot get this to work.

3 Answers, 1 is accepted

Sort by
0
Accepted
Alexander Popov
Telerik team
answered on 30 May 2014, 03:06 PM
Hi Eric,

Model binding in ASP.NET MVC is not related to Kendo UI and it falls outside the scope of our support services. Nevertheless I tried to recreate this scenario, but everything is working as expected on our side (see screencast). 

Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Eric
Top achievements
Rank 1
answered on 30 May 2014, 03:11 PM
Alexander,

Thank you for taking the time to produce that screen cast for me. You have a few things different than I do with regard to the MVC (specifying the type as well as having the return type off the controller be a JsonResult rather than an Action Result) up so I will change the settings on my end and see if I cant get it to work as you have it.

Again I appreciate the time you took to create that example for me.
0
Eric
Top achievements
Rank 1
answered on 30 May 2014, 05:37 PM
Alexander,

I wanted to let you know that I updated my project and now passing the object to the controller works exactly how I wanted it to, this will make processing the data server-side considerably less taxing. THANK YOU! I have marked your answer as correct.
Tags
Data Source
Asked by
Eric
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Eric
Top achievements
Rank 1
Share this question
or