I have calendar1 in my retool app. When an event is clicked, I am running this script:
function selectRowWithMatchingEventData(selectedEvent) {
const eventStudentId = parseInt(selectedEvent.student_id);
const rows = student_info_table.data;
const matchingIndex = rows.findIndex(row =>
row['student_id'] === eventStudentId &&
row['teacher_openings_id'] === parseInt(selectedEvent.openingId) &&
row['gusto_id'] === selectedEvent.gusto_id &&
row['opening_teacher_id'] === parseInt(selectedEvent.teacher_id)
);
if (matchingIndex !== -1) {
const queryIdField = rows[matchingIndex]['query_id_field'];
console.log("Matching Row Index:", matchingIndex);
console.log("Query ID Field:", queryIdField);
const rowWithMatchingQueryId = rows.find(row => row['query_id_field'] === queryIdField);
if (rowWithMatchingQueryId) {
student_info_table.selectedRow = rowWithMatchingQueryId;
console.log("Selected Row:", rowWithMatchingQueryId);
} else {
console.log("No row found with matching query_id_field.");
}
} else {
console.log("No matching row found.");
}
}
selectRowWithMatchingEventData(calendar1.selectedEvent);
The console returns this:
Matching Row Index:
- 844
Query ID Field:845
Selected Row:
{query_id_field: "845", student_id: 3113, student_fname: "N***", student_lname: "M*****", enrollment_date: "2017-01-14T01:00:00.000Z"…}
The table I am trying to set the selectedRow in is student_info_table but the state of the table doesn't change. When a user double clicks a row in that table a modal pops up that is the students profile - I'd like that to happen from the calendar too, and this seems like the easiest way.