Setting selectedRow from another component

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:

  1. 844

Query ID Field:845

Selected Row:

  1. :arrow_forward:{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.

Simplified with:

SELECT query_id_field
FROM {{ student_info_table.data }}
WHERE student_id = CAST({{calendar1.selectedEvent.student_id}} AS INTEGER)
AND
teacher_openings_id = CAST({{calendar1.selectedEvent.openingId}} AS INTEGER)
AND
opening_teacher_id = CAST({{calendar1.selectedEvent.teacher_id}} AS INTEGER)
AND
gusto_id = {{calendar1.selectedEvent.gusto_id}};

And then:

student_info_table.selectRow({mode: 'key', key: get_query_id_field.data[0].query_id_field })

But I have to open the table up for the change in selection to actually occur.

Is this a bug?

Hi @CCM, using "selectRow" is definitely the way. "selectedRow" is read only. When you say "I have to open the table up for the change in selection to actually occur," does it mean your table is hidden when you are running "selectRow"?