Table populated with Array - Need to auto scroll to bottom row / rearrange Array

Hi all,

I have a table which is populated with data from an Array.

The Array gets added too via an onclick action, and therefor the table will continue to show the new row’s.

My question is, does anyone know how I would go about either auto scrolling to the newest row(the bottom one) every time I add to the Array, or showing the newest row on top always?

As you can see here, when the new item is added to the Array, it gets populated as the last row in the table, therefore, I would need to manually scroll to the bottom of the table to see it.

Cheers,
Ray.

Hey Ray,
You can just add one more dynamic event on click - Array Reverse :slight_smile: It will reverse the array and place the latest on top.

Hi @Teodor,

I was thinking that reverse would do that, however, when I add it to the onclick i get an error in the console.

                  <button class="btn btn-primary btn-lg w-100 h-100" dmx-html="strName" dmx-bind:value="mmValue" dmx-on:click="SubTotal.setValue(formtotalcost.cost.value);formtotalcost.cost.setValue(SubTotal.value.toNumber() + (value.toNumber());arrshoppingcart.addUniq({'productid':productid.value,'productname':productname.value,'price':price.value});arrshoppingcart.reverse()">Button</button>

Ray.

1 Like

I see opened left bracket which is not closed. Better remove it as it is not needed:

<button class="btn btn-primary btn-lg w-100 h-100" dmx-html="strName" dmx-bind:value="mmValue" dmx-on:click="SubTotal.setValue(formtotalcost.cost.value);formtotalcost.cost.setValue(SubTotal.value.toNumber() + value.toNumber());arrshoppingcart.addUniq({'productid':productid.value,'productname':productname.value,'price':price.value});arrshoppingcart.reverse()">Button</button>

Perfect! Thank you.

Just to note, I needed to reverse them back again before adding an item and then reverse again. This was so I can keep the correct order after adding an additional item.

Ray.