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

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
achenet
Hello, I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind. However, when I launch mix phx.server, I get an error...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
Cxx-mlr
I’m working on a small exercise involving update_in/3, and I came up with this solution: data = %{ name: "Periodic Table", category:...
New
ChrisAmelia
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication): toke...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
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
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews