Change currentItemIndex when clicking on an element in a repeater

If you add a table to a page then clicks a row it triggers an event to change the currently selected index in that dataset. Which means you can easily connect another repeater to filter on that selected item.

I want to be able to do this with a repeater instead of a table for design freedom. So when I click an element inside a repeater I want to be able to select action ChangeIndex so when clicking a button in a repeater for example that could trigger another repeater on the page to filter on that selected item.

1 Like

Hi Andreas

If repeater 1 is connected to DB and use that data to filter repeater 2 then I think this will work.
Try this ;

export function repeater2Filter_onClick() { // this is button inside the repeater1
const idOfItem = event.context.itemId;
let rowData;
$w(β€˜#repeater1’).data.forEach((item) => {
If (item._id === idOfItem) {
rowData = item;
$w(β€˜#input1).value = item.title} //
filterRepeater2() // function to fitler the repeater 2 to be called onReady function.
});

Good Luck!!

DA

hey, I know how to code it I was just thinking of all the non coders who needs this function and don’t want to use Table as the only way to connect two datasets and filter them without code. But thank you anyway for the code snippet.

Hi Andreas

I know you are professional coder unlike me picking pieces to learn, lol.
Apology by the way, I thought you were asking.

Only thing make me worried is when using two repeaters on the same page could probably load the page slower.

DA