+1 vote

I'm trying to display a high score list that is stored in an Airtable. I can connect to the Airtable and display it (kinda) like this:

*service: highscore
	*path: /highscore
	*send: {"maxRecords" -> 10}
	*method: GET
	*success
		>> response = it["records"]
	*error
		An error occurred!

>> i = 0
*while: i < response.size
	*html
		<table>
		<tr>
			<td> {response[i]["fields"]["Name"]} </td>
			<td> {response[i]["fields"]["Score"]} </td>
		</tr>
		</table>
	>> i = i + 1

However, I'd like to sort the collection to get the top 10 scorers, but can't figure out the right way to sort both score and name simultaneously.

I'd also like to know how to display this content in a name table with Name and Score headers, but can't quite figure out the right way.

by (130 points)

1 Answer

+1 vote

Hi there,

To answer your questions:
Sort the collection: you might want to sort at the time you are pulling the data from Airtable, could be something like:

path: /table1?sort%5B0%5D%5Bfield%5D=Score&sort%5B0%5D%5Bdirection%5D=desc

About table header: you might want to use <th></th> outside of your while loop.
Hint: put the html table into variable before showing it

Check this out, I built a sample that might help you; https://www.guidedtrack.com/programs/25353

References:
https://docs.guidedtrack.com/manual/advanced-options/use-service-to-embed-outside-apps-and-other-tools/

by (160 points)
Welcome to Guidedtrack Q&A, where you can ask questions and receive answers from other members of the community.
134 questions
144 answers
55 comments
40 users