Hello I have a kendo grid in MVC which currently works fine. I am making an Ajax request to read the information on the grid and everything works fine. However, I want to send another object into the same json coming from my action result that populates the grid as follows:
public JsonResult ReadElements([DataSourceRequest]DataSourceRequest request)
{
// this is my data that i want to populate in the grid
var result = GetMyGridElements().ToDataSourceResult(request);
//returning the following line allows my grid to be populated correctly
//return Json(result, JsonRequestBehavior.AllowGet);
var otherInfo = GetOtherInfo();
//i want to return something like the following:
return Json(new {result, otherInfo}, JsonRequestBehavior.AllowGet);
}
However, this results in a grid error. I have tried to bind to the following events to see what I could accomplish:
.Events(e => e.DataBinding("MyGrid.DataBinding"))
and
.Events(e => e.RequestEnd("MyGrid.RequestEnd"))
which use the following defined functions:
MyGrid.DataBinding = function (e) {
debugger;
}
MyGrid.RequestEnd = function(e) {
debugger;
}
I see that the only difference on the request end function is the way the e.response object behaves. On the non-working example the e.response object has a result and a otherInfo properties, whereas in the working example the content of the e.response object match the contents of the e.response.result object. So I tried doing this:
MyGrid.RequestEnd = function(e) {
e.response = e.response.result;
}
However, on the databinding event, the e.items object is empty on the non-working scenario and contains all elements in the working scenario and my grid does not display any element
Basically my question is:
is there a way that these two events connect with each other? how can I programatically select which information will be bound to the grid when multiple information is present on the response of the ajax request?