# Next/Prev Action Buttons?

**URL:** <https://community.glideapps.com/t/next-prev-action-buttons/74409>\
**Category:** Ask for Help\
**Created:** [June 26, 2024, 11:00pm UTC](https://community.glideapps.com/t/next-prev-action-buttons/74409 "2024-06-26T23:00:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emmett\_M](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/emmett_m/32/60683_2.png) [@Emmett\_M](https://community.glideapps.com/u/Emmett_M)\
**Post date:** [June 26, 2024, 11:00pm UTC](https://community.glideapps.com/t/next-prev-action-buttons/74409/1 "2024-06-26T23:00:33Z")

</div>

I want to build a swipe style component for my app. I need to have a next & previous action button to go through the items randomly in the table. I have it working using 1 max pages but would prefer the button UI.

Cheers

 ![Screenshot 2024-06-26 at 23.59.00](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/3/c/3cd508d7b2c7802acf08726fd6993031e6168ffa.png)

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [June 27, 2024, 1:35am UTC](https://community.glideapps.com/t/next-prev-action-buttons/74409/2 "2024-06-27T01:35:25Z")

</div>

> [@Emmett\_M](#):
>
> go through the items randomly in the table

Wouldn’t you want it to follow a sequence? If you do it randomly, do you want the left button to go back to your previous view? It can be tricky.

---

<div class="post-metadata">

**Author:** ![Emmett\_M](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/emmett_m/32/60683_2.png) [@Emmett\_M](https://community.glideapps.com/u/Emmett_M)\
**Post date:** [June 27, 2024, 9:53am UTC](https://community.glideapps.com/t/next-prev-action-buttons/74409/3 "2024-06-27T09:53:47Z")

</div>

Yea I guess with the random order it could be hard to go back to the previous. Even if I can get it working in order would be a step in the right direction.

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [June 27, 2024, 1:58pm UTC](https://community.glideapps.com/t/next-prev-action-buttons/74409/4 "2024-06-27T13:58:42Z")

</div>

> [@Previous and Next Record in Detail View](https://community.glideapps.com/t/previous-and-next-record-in-detail-view/65449/3):
>
> Here is an alternative solution that doesn’t consume updates. Basically you create an array with all the items and iterate through it using custom Next/Prev buttons. Link: [https://www.loom.com/share/07057718ade34344869c0bc8d9644ea7](https://www.loom.com/share/07057718ade34344869c0bc8d9644ea7?sid=ffc45748-17cf-4af9-8a8a-5d80943eb0ff)

Here’s a video from @grumo .

---

<div class="post-metadata">

**Author:** ![Emmett\_M](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/emmett_m/32/60683_2.png) [@Emmett\_M](https://community.glideapps.com/u/Emmett_M)\
**Post date:** [June 27, 2024, 2:02pm UTC](https://community.glideapps.com/t/next-prev-action-buttons/74409/5 "2024-06-27T14:02:10Z")

</div>

![Screenshot 2024-06-27 at 15.01.17](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/5/b/5b15ee5c39cbcde9986eee678a586ea4f422e8d0.png)

I managed to get it working like this. But now stuck on adding a new row and continuing the row number sequentially

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [June 27, 2024, 2:08pm UTC](https://community.glideapps.com/t/next-prev-action-buttons/74409/6 "2024-06-27T14:08:51Z")

</div>

- Add a rowID column to your table.
- Add a lookup pointing to that rowID column so you get an array of rowIDs.
- Add a find element index column, find the current row’s rowID amongst the array. It would give you a 0-based list of index that you can use to calculate your previous and next.

Only caveat here is if you need the first item’s previous to be the last one, then it would involve a rollup to get the max number of items, then some math/if-then-else columns (or a JS column).

---

<div class="post-metadata">

**Author:** ![Emmett\_M](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/emmett_m/32/60683_2.png) [@Emmett\_M](https://community.glideapps.com/u/Emmett_M)\
**Post date:** [June 27, 2024, 2:26pm UTC](https://community.glideapps.com/t/next-prev-action-buttons/74409/7 "2024-06-27T14:26:08Z")

</div>

Yea , its a tricky one just for a simple function. I’ll give this a try and see can I figure something out
