401
Views
5
Comments
Local List Search
Application Type
Reactive
Service Studio Version
11.53.40 (Build 61951)

Hello, 

I want to know how can i search in a local variable list without losing the original list and when editing an input in the filtered list, i want it to be in the original list after removing the filter.

E.G.: I have a local list with inputs filled with car brands, but want to search for a specific one and change something in is name, after that i want to clear the search and see the full list and the car name changed.

2023-08-28 07-00-10
Paulo Torres
Champion

Hi,

You can use ListIndexOf to search the record you want and after with the position you can change the name affecting the list! And that's it :)

2020-03-08 20-34-47
Alexandre Santos

Hi, i'm not looking for a specific record, i just filter a list and might want to change a record.

E.G.: when i do a search by brand, and change the model of a car, when i remove the search i need to reset the local list and thus resulting in no changes made.

2020-03-08 20-34-47
Alexandre Santos

Hello, i do use the list filter, but with a local list, i need to reset it and the changes will not be made.

Code print: 

2021-09-06 15-09-53
Dorine Boudry
 
MVP

well,

just imagine what you would do if your cars were in a database instead of a local list, and mimic that pattern.

So, you'll need 2 local lists, one holding all values (the role normally for a table in a database) and one holding the values you want to show to your user.  I think you are already on that path, as i see both a cars and a cars_reset.

- Whenever filter is changed, you apply listfilter on the full list, and assign result to show list.

- Whenever a value is changed in show list, you need to execute logic to change the corresponding value in the full list (either an onchange at every change, or at the very last, before applying another filter to the full list and update the show list, so at the beginning of or your search_onchange)

In order to do that, you need a unique value for every record.  For this, your example is now a bit too simplistic, I think, for example you have 2 audi's, you can't know which of the 2 is updated.  Each row in your full list should have a unique id, that is also copied to the showlist when doing the listfilter.  Then before the next listfilter, you can first go through each showlist record, use listindex with this unique id to find corresponding row in fullist, and update that value.

Not sure why you would even want anything like this, though, what is the point of your application, just exercising how to work with local lists ?  How do you persist you data for later ?  Why not do that at every change and then requery your source ?

Dorine

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.