I'm trying to launch or populate another datatable based on values from another table.
For example, I'm using below code to get all "pending" items for the current user:
$(document).ready(function(){
loadPendingData();
});
function loadPendingData() {
//REST call
var requestInfo = _spPageContextInfo.webAbsoluteUrl + "/_api/web/Lists/getByTitle('AbsenceRequest')/Items?$filter=(((Manager0 eq '" + _spPageContextInfo.userEmail + "') and (Status eq 'Pending')) or ((Status eq 'Pending') and (AltManager eq '" + _spPageContextInfo.userEmail + "')))&$select=Id, Absentee, RequestType, ActivityType, EventDate, EndDate, Status";
var ajaxPending = $.ajax({
url: requestInfo,
type: "GET",
dataType: "json",
headers: { "accept": "application/json;odata=verbose" },
success: mySuccHandler,
error: myErrHandler
});
}
And in my first datatable, I have a column that returns the following:
"aoColumns": [
{//edit link
"render": function(data, type, row) {
var rowID = row.ID;
var rowEventDate = row.StartDateISO;
var rowEndDate = row.EndDateISO;
return '<a href="javascript:modCheck(' + rowEventDate + "," + rowEndDate + ');">Check</a>';
}
},
On the second datatable, I want to use the rowEventDate
and rowEndDate
values to call another REST. Basically, when user clicks the check
link, it should populate the 2nd datatable with items that are within the same date range. The purpose is for the managers to view all approved absences within the same date(s) requested before approving the current request. The REST call is as follow:
function modCheck(rowEventDate, rowEndDate) {
var webAbsUrl = _spPageContextInfo.webAbsoluteUrl;
var checkInfo = webAbsUrl + "/_api/web/Lists/getByTitle('AbsenceRequest')/Items?$filter=((StartDateISO ge datetime'" + rowEventDate.toISOString() + "') and (EndDateISO le datetime'" + rowEndDate.toISOString() + "'))&$select=Id, Absentee, RequestType, ActivityType, EventDate, EndDate, Status";
var ajaxAllAbsences = $.ajax({
url: checkInfo,
type: "GET",
dataType: "json",
headers: { "accept": "application/json;odata=verbose" },
success: mySuccessH,
error: myErrHandler
});
}
But it's not populating the 2nd datatable. It doesn't have to be on the same page, it could be on another page but I just cant figure out how to pass the values from one page to another.