|
function onChange(args) {
var value = args.event.target.getAttribute("value");
var staff = staffData.filter(function(staff) {
return staff.StaffName === value;
});
var location = locationData.filter(function(location) {
return location.StaffLocation === staff[0].StaffLocation;
});
if (args.checked) {
if (scheduleObj.resourceCollection[0].dataSource.length === 0) {
scheduleObj.addResource(location[0], "StaffLocation");
} else {
var resource = scheduleObj.resourceCollection[0].dataSource.filter(
function(resource) {
return resource.StaffLocation === location[0].StaffLocation;
}
);
if (resource.length === 0) {
scheduleObj.addResource(location[0], "StaffLocation");
}
}
scheduleObj.addResource(staff[0], "StaffName");
scheduleObj.dataBind();
} else {
scheduleObj.removeResource(value, "StaffName");
scheduleObj.dataBind();
}
} |