Repeat row question

I have a repeat row like this

<div class="row redrow" dmx-repeat:repeat1="`fare.grossamount`).groupBy(`searchKey`)">

I would like to bind data inside the repeat as i normally would but I only want to display a single result instead of multiple. I have to use the repeat to get all the data so i can group and sort it first.
I tried returning a single result like this but it gives multiple results

<div class="col-12 col-sm-6 text-center airline-output" dmx-hide="$index > 0"><h4>Airline</h4>{{$value[0].airline}}</div>

So to get around it i do something i am ashamed of which is that dmx-hide="$index > 0"

LOL, any ideas to do it better please.

its an array
so put [0] to get the first record in the data

I tried that already but no matter where i put the [0] i could not get it to do what i wanted.

Can you show me where on that please.

EDIT: The above code is what i have now, that gives me all the data from the first groupBy, tried doing {{$value[0][0].airline}} to get the first record from the first Group.

I don’t know the structure of your data, but try:


I would not use a repeater if you only wanted to get a single value.

1 Like

Thanks so much Patrick, that taught me something very valuable
I so no have to be inside a repeat to sort an array, I thought i HAD to, like no other option.
This opens up a whole new world of possibilities to me, thank you.

This is what I landed up having to do to get it working, seems it is a hefty multidimensional array returned.


Sorry one more slightly strange question here

is there a speed advantage of these 2 solutions

Solution 1 (I think I am querying the data twice and sorting twice and grouping twice)


Vs Solution 2 (By adding the core into a variable I should only be sorting and grouping once and then just extracting what i need, but the var has much more unused data than in solution 1)

<dmx-value id="var1" dmx-bind:value="`fare.grossamount`).groupBy(`searchKey`).values()[0][0]"></dmx-value>

So I am a little unsure here.

For performance the second solution is better, you indeed only do all the sorting only once.

1 Like

Thanks so much for confirming that now i am busy trying to add failover to my geo checking solution, this actually works by the way, never thought it would but it does.

dmx-param:lat="(geo1.status == 'OK') ? geo1.coords.latitude :" dmx-param:long="(geo1.status == 'OK') ? geo1.coords.longitude :"

So it uses Wappler coords if the user has it set to allow and IP Geolocation if they block it.