I’m using a local database and displaying the data with a data viewer. Is there anyway to sort the data in this viewer alphabetically? I see that we have a list block that can help with sorting but I don’t see how to bind the data list viewer to this block. It looks like the only way to bind this viewer is in the setup design screen. I’m using the new drag and drop UI if that maters. Thank you
Is see that there is a list viewer control and that would help with the sorting because I could bind that to a sorted list object but the problem would be that I need to use the swipe left and right features. Seems like each control has something I need but is also missing something I need.
Before I make some pretty big changes I want to run this by you folks. I can now easily bind the list viewer to the data object using the list property of that data object. The issue I’m having now is that I have no idea what row id I’m looking at. If I click on a row in the list it really has nothing to do with the row in the data object. So that means I can no longer use the index number because once I sort the list the arrangement of the rows will be different from that in the data object. Is more only option to now create a JSON object from the data object and work from that?
I designed this sample project for a similar request from another person.
https://x.thunkable.com/projectPage/60d78e2a5e21e600110b78b4
Maybe it would help you
Thank you for this. Here is where I’m currently stuck. I see you have a list that can sort, but how would you be able to allow the user to click on a row and have app move to a new screen that can look up that selected row? I’m struggling to find a way to pass a row id to the next screen for look up. As I mentioned, you cannot use the index of the list because each time you sort it the index of the rows in the list will not match you backend object (JSON or Database). This is kind of a bugger and I’m rather surprised that data viewer does not have a sort feature.
Easy.
In your object, have a property
for your row ID, when you select the row in the list viewer
it will be the index of the object in your list of object. Read the row ID from the object and store it to an app variable
.
I hear what you’re saying but I don’t see how this will work with a local database. Let me explain so you can show me where I’m missing the boat.
I have a local database with these values
Column NAME
Value Bob
Value Mike
Value Steve
Value Andy
Value Sue
Value Andy
I want to display them on a screen in alpha order. Right now the only way to do this is via the list viewer because I cannot see any way to sort data in the data viewer. So my first question to you would be, is that true? This is a shame because now I loose the swipe left and right features.
OK, so in order to get these values in alpha order, from what I’m reading here, I would have to do the following.
- Pull all the data out of the local database and put it into a JSON object (I’m not sure how I would even do that because the data object “list of values” feature only lets you pull one field at a time into a list)
- I still don’t see how I can sort this JSON object. Only a list can be sorted so would I have to convert the JSON to a list?
- Now take the list object and connect that to the list viewer. I understand that the index of the list should technically be in sync with the JSON file but now I need to make sure of that and have to reference the JSON file to find the actual row id for the record in the database to make any changes and / or pull out any more data?
This seems quite over complicated when the data viewer should just have a sort feature. I’m not even talking a really outrageous feature, it just seems logical and should have been part of the control before it was even released.
Try this quick project
https://x.thunkable.com/projectPage/60e8375f1170e500118e0e54
[Edit]
I just added another sorting option. Remix the project to see the updated option.
See the latest update of the sorting sample project.