Trying to pass a value from an async call back to a grid column cell template. Obviously returning a value from an async call can be difficult. How do I get a result back into the kendo grid cell?
....
field: "PTORecorded",
title: "PTO Recorded",
template: function (data){
getData(data).done(handleData);
}
},
----
function
getData(data) {
var
person = data.Person;
return
$.ajax({
url : url + person,
type:
'GET'
,
headers: {
"Accept"
:
"application/json; odata=verbose"
},
});
}
function
handleData(data) {
var
ptoArray = [];
$.each(data.d.results,
function
(index, item) {
if
(item.PTOValue !=
null
) {
var
_item = item.PTOValue;
ptoArray.push(_item);
}
});
var
ptoRecorded = 0;
for
(
var
i = 0; i < ptoArray.length; i++) {
ptoRecorded += ptoArray[i] << 0;
return
ptoRecorded;
}
}
I'm basically trying to call a remote datasource, filtering it via a value in the grid row (data.Person), calculating a returned value, and passing it back to a grid cell template. How do I get that async call to pass a value back to the grid? I know the async call presents a problem. Suggestions?