2

I need to pass various parameters back to my controller method, which I am able to do in the following ways:

Parameters From Model:

.Read(read => read.Action("CPos_Read", "Reporting", new { LocCode = "#=LocCode#" }))

Parameters From Javascript Method:

.Read(read => read.Action("CPos_Read", "Reporting").Data("GetFilters"))

function GetFilters() {

    var ParamList = [];
    var Param = ":";

    Param = "DateStart:";
    Param += $('#DateStart').val();
    ParamList.push(Param);

    Param = "DateEnd:";
    Param += $('#DateEnd').val();
    ParamList.push(Param);

    return { Params: ParamList }
}

I have a requirement to pass both the LocCode parameter from my kendo grid model, and the additional parameters from the Javascript function. In other words, I need to be able to combine both of these to pass back to my controller.

Ideally, I would like to be able to pass the LocCode parameter to my Javascript method.

B.Hawkins
  • 353
  • 5
  • 13
  • Possible duplicate of [access model in javascript asp .net mvc razor](https://stackoverflow.com/questions/21391402/access-model-in-javascript-asp-net-mvc-razor) – Richard May 18 '18 at 10:27
  • Please bare in mind that the model is not a view level model. It is a model that the kendo grid is assigned to. I have multiple kendo grids within my view (sub grids), each with a different model. – B.Hawkins May 18 '18 at 10:32

1 Answers1

2

I have found a working syntax for passing a kendo grid's selected model value into the Javascript function:

.Read(read => read.Action("cPos_Read", "Reporting").Data("GetFilter(#=LocCode#)"))

I researched for quite a length of time before I posted here and did not find any examples of this being done, even though it appears quite simple. Hopefully the code above will help someone in the future.

B.Hawkins
  • 353
  • 5
  • 13
  • Where is the Data() method defined? It doesn't seem to be available to me in Telerik UI version 2018.1.117. – Lee D Sep 26 '18 at 14:56