Search bar issue

it works fine but something not correct when it brings me the inside details:

my blocks:

result:

help me please

Hi there,

I don’t think the problem is in .OnTextChanged but in .Click because in the ListView you’re regenerating the list with the filtered elements, so the first element will always return index 1, even if the element you see should actually be index 5.

There are many solutions to this problem, one is the following:

While creating the filtered list, you could use a list variable filteredIndex in which you store the indices of the elements currently being displayed. Then, when you handle .Click, you use position to select the index from filteredIndex and use that result to retrieve the item from the main list.

Depending on how you structured your data, you can also use .OnTextChanged(title) and use indexInList to select the correct index in the main list.

ok, i understand what you said…then how to filter the index? here is my block for the list view image and text:

  • Create a new variable filteredIndex
  • In .OnTextChanged, for each element being filtered, add its index to filteredIndex
  • In .Click, select position from the filteredIndex variable, which will return the real index of the element

Then you’ll be able to set all the labels using the correct index.
Give me a minute and I’ll make a visual example.

visual example is better to learn how and what you exactly did :blush:

i was looking to the block you show me before for the filtered elements but didn’t know to to mix it with the OnTextChanged :sweat_smile:

Remember to clear filteredIndex (for the nex search)

1 Like

the second part is ready i guess..

the first part !! where to insert: add items to list list global filteredindex?
it can’t join the : call view image and text add item..

Add it above or below, as long as it’s inside the contains check.

And make sure to clear the filteredIndex variable (put it right under .ClearList).
blocks(124)

i did but still the same result:

Did you add this part? :grin:

1 Like

the last part didn’t appeared to me :sweat_smile:

the result:

thank you so much :face_blowing_a_kiss:

Ah, no problem at all, I’m glad you solved it :partying_face:

I wish you a great day.

1 Like

i wish you a great day too :blush: