B.Hawkins
B.Hawkins

Reputation: 363

Kendo UI - Pass parameter to JS function within read().data()

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.

Upvotes: 2

Views: 2576

Answers (1)

B.Hawkins
B.Hawkins

Reputation: 363

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.

Upvotes: 2

Related Questions