Dynamically swap the Dataset fields that are connected to a WIX Pro Gallery

Hey folks

On a dynamic page, I connected a dataset to a gallery. I also placed a dropdown menu that users can interact with to select wich category of our work they want to see. The whole filter thing happens in CORVID code and works like a charm:

import wixData from "wix-data";
$w('categorySelector').onChange(function() {
    $w('workDataset').setFilter(wixData.filter().contains('category', $w('categorySelector').value));
})

The gallery “Titles” are connected to the dataset column that stores the project names. This is fine for most of our categories, but in one category, we show work that we’ve done collectively with partners. For this category I’d like to display the partners name as the “Title” of each individual gallery item. Starting the action, when said category is selected is quite easy:

$w('categorySelector').onChange(function() {
    $w('workDataset').setFilter(wixData.filter().contains('category', $w('categorySelector').value));
    if($w('categorySelector').value === 'partners') {
        //Do the reconnection magic here....
    }
})

But i have absolutely no clue how i can reconnect the gallery titles on this condition. I thought, I could iterate over the datasets items with a Javascript “for”-loop and refill the gallery like that, but everything I tried broke the entire site.

Has any of you ever run into the same problem or even solved it?
I’d be glad for any help I can get. Thanks in Advance!

Cheers
Tim