Hi all,
I’ve made a couple of threads recently about needing help with creating a search bar and adding data to my project from a Google Sheet. After a week of reading multiple Community threads for help, watching videos and some blind trial and error, I believe I’ve finally made progress.
But I need help with the next section, which is to repeat my code without having to manually input code for each row. Let me explain with as much detail as I can…
So in my app, there’s a marketplace to trade Pokemon Cards. When you load the ‘Trading Market’ page this is what you are met with (pictures are just placeholders for now).
The following code is executed…
The local table/database is completely wiped clean of any lingering info (this may not be necessary, but I was having some issues without it so I put it in there for peace of mind). The first ‘Default’ Data Grid is refreshed, which is directly linked to the corresponding Google Sheet. It is then made visible and the second ‘Filtered’ Data Grid is made invisible.
The Google Sheets API/CSV is then called, with the usual Parsing data magic that occurs.
After this, I’ve had the page create a new row in the Local table/Database. It then updates the specific columns and rows based on the API/CSV data. Now, before I couldn’t get it to do this until I asked it to ‘get value’ from the Google Sheets document directly.
I have also set this up for the second row…
The final part is when a user types in their “Search” in the ‘Search Bar’ and ‘Clicks’ the ‘Search Button’ it activates the below code to identify if the row has the used phrase or not.
If the phrase matches the row data, the row remains in place…
If the phrase doesn’t match the row data, the row is deleted…
This part is unrelated, but when a user clicks the item, it takes them to another screen which will contain all of the info and options…
Now what I need help with is finding a way to loop this action for every row that could contain data. At the moment, I only know how to proceed by manually writing out this sequence for every row of data. It’s not ideal, but it can be done to an extent, but I anticipate it would be a HUGE amount of code (especially if the number of listings reaches the hundreds) and I wanted to know if anyone has any idea on how to make this smaller and more dynamic, so I don’t need to manually ask it to pull in data for every row.
I’m sure I will get some comments about some of the unnecessary code in this, but I’ve played around with a lot of stuff in the past week and had no success and this is the first time I’ve made this breakthrough so I’m super stoked - so if anyone does have any suggestions for limiting the amount of code/blocks I’m happy to take it on board
Any help is greatly appreciated!