Data Viewer List not List viewer, Sort Alphabetical

I have a Data Viewer and I want to have the items in the Data Viewer sorted to make it easier to find an item to either Edit or Delete

Can anyone assist with Sorting Alphabetically

1 Like

DVL (Data Viewer List) echoes what’s in the the data table/database behind it. Sort the data source and your DVL will show the list sorted.

1 Like

Hi muneer
Thanks for the response. First time using data viewer.
Currently I believe from the code blocks I am not saving the data but just viewing. I have db where I have ToDo and Done for slide sideways. But my data is not saving there. I will revisit and read up.

Regards
Barrie Fox

1 Like

The Data Viewer List (DVL) just pulls data from a data source and displays it. It’s not possible to “just view” the data but “not save it.” Think of the DVL as a window that you’re looking through to see a fancy car. If you change the color of the window, the car will look a little different but it’s still the same car.

However, when you use the Create/Update/Delete blocks as in your screenshot, you’re directly editing the database. So those changes will appear in the DVL.

If you want to sort the data, as @muneer says, you’ll have to sort it in the database itself. The DVL will just display the current database values.

2 Likes

@tatiang
Tks Tatiang
I am a little confused with this and will include as much info as I can.
I have a table called checklist. I expected to see any added data viewer items in this checklist. I see any added checklist items on the screen but cannot see where it is actually saving each item

Could you check the code block in this response. This is my add button

image

image

This image is of the set up of the data source. As you can see I am using right and left swipe and that displays on the screen correctly and seems to save somewhere.

This image is of the App screen for the data viewer and as you can see there are items in the that are not in the data source called checklist

image

I have also emailed the App to the phone and it works, I have used live test and it works but not able to sort as I cannot find where it is saved to

1 Like

Your table called Checklist is your local database. The two rows (“a” and “b”) are the initial data that your app starts with. Then, using blocks, you’re saving new values (“bb” and “cc”) to that same database.

Local databases use internal phone storage. There’s no way to “look at the database” other than to get the value of a row or cell and assign it to a label, etc.

Also, it may work to stack the create row in Checklist and set TXT_item_cl's Text blocks but it’s not best practice. If you want to be sure the text is set to “” (blank string) after the row is created, you need to move the set TXT_item_cl's Text block inside of the “do” section of the create row in Checklist block.

2 Likes

@tatiang
Thanks again.
Then it is working fine… But is there any way to sort the LOCAL DB in alphabetical? As I cant see it I cant apply a sort.

1 Like

Hi Muneer
This is a Data Viewer List and not saved to to Cloud or Google sheets, otherwise i could sort it in there. It is saved to the phone. I really need to use DVL as it is a list of items where the user slides sideways to mark as ToDo or Done. If there was a way of marking List Viewer with ToDo or Done I would much rather use list Viewer. Then Sorting is Easy!!! My new version of the App already has 2 screens with lists and they sort but they do not need to marked as Done. It is a list of things to do before driving off for a trip away. So they need to keep the same list and flag them as Done. CaravanMate is currently live on the stores since 2018 but a fresh new version is almost complete. Just got this one list to work out sorting.

1 Like

There is no easy way to do that. But if the data in the Local Table is originated from Firebase then get the list in Firebase and sort it then insert the corresponding rows in the Local Table.

If, however, the data is originally stored in a Local Table then you might need to sort the data into another table.
I prepared an example to make it easy.
https://x.thunkable.com/projectPage/6103dec760c70500ef73d4b0

In this example I have **unsorted ** data in one of the tables and I programmatically go through each row to save the row ID in a sorted fashion in a list and then I iterate through the list appending the data in the second table sorted.

2 Likes

@muneer

Thanks Muneer I cant thank you enough but I still have a little issue. I copied your blocks and had a little problem with the "Count with this row. I created a variable for this which you did not have in your project.
How did you create “This Row” without a variable???

When I sort it says 4 rows sorted but does not populate the DVL (ChecklistDB2, the sorting DVL)

image

Here are my blocks

1 Like

The variable “thisRow” is created by renaming the default “i” or “j” of the loop component. When you click on the default variable you should see a context menu with “Rename” option just before the last
image

Select this option to rename the “i” or “j” to something more meaningful. However, the code should not be effected if you use the default “i” and “j”.

Tks muneer

I got it working, now I will see how I will blend it in to my App

2 Likes