dbsimmons64

dbsimmons64

Hi All

I’m using the amazing flop/flop_phoenix libraries for pagination. I’m using liveview streams to retrieve a list of customer transactions ordered by a date field. The pagination works really well but when I create a record it gets inserted at the bottom of the current paginated list i.e. it doesn’t take account of the date entered. If I reresh the page all works well and my new record appears in the correct place.

Does anyone know if it is possible to retrieve the newly created record but in the correct place in the paginated order.

As an example. If I create a record with a date that would normally appear on Page 5 of my paginated list but I’m looking at Page 2 when I create the record I’d really like the display to update/jump to Page 5.

cheers

Dave

Showing Posts 1 to 2

sodapopcan

sodapopcan

Hello and welcome!

Flop is very nice indeed :smiley:

I also have trouble deciding on UX for this type of thing. In short, Flop isn’t going to deal with this for you (if that’s what you’re asking). While there are some tricks online, as far as I’ve ever known there isn’t any reliable way to find out what page something is on other than loading page after page until you find it (or using some trick that gets you close). Or course you can just load the IDs but if you have a ton of rows this isn’t efficient at all. If you don’t have a lot of records then you could load all the ids into a list, paginate it yourself, and find it but ya, still not ideal!

In terms of adding a record to the correct spot on the current page, all I do is reset the stream and reload the records. This is by far the path of least resistance. I’m not worried even a little bit about the performance here, especially since BEAM doesn’t need to build the entire world just to run a web request. It could cause problems if your app is highly collaborative. It could help to know more about your app but I usually just try and design the UI around these problems. I’ve even worked on a scheduling app where the list of work orders was so huge and constantly growing and changing that it didn’t even make sense to paginate it—it was search-only.

dbsimmons64

dbsimmons64 OP

Thank you so much @|sodapopcan. I’ve been thinking about this for a few days now and coming to the same conclusion as yourself (reset the stream and relaod the records).

cheers

Dave

— All posts loaded —

Where Next? Top

Trending in Questions Top

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews