Pagination With Custom Javascript and Supabase

I’m using Supabase for my backend, and I’ve successfully implemented pagination in WeWeb in most cases. However, I have a specific use case where I need custom sorting on a text field that includes a mix of letters and numbers, like a, b, c, 1, 1a, 1b, 2, 3. This sorting is non-standard, so I’m using custom JavaScript to fetch and sort my data.

The issue is that when I enable the data source collection pagination in WeWeb, the collection list displays nothing. It seems my custom JavaScript conflicts with WeWeb’s built-in pagination.

So what I would like help with is:

  1. Add pagination to my collection list when using custom JavaScript.
    or
  2. Achieve this type of custom sorting within WeWeb directly (so that I can use its built-in pagination).

Thanks

Can you attach your setup?

This pic is returning the list like i want it without pagination

This is when I turn on pagination in the data source you can se the data is still coming in but its not showing in my list.

Have you tried checking out the Dev Tools → Console? I’m pretty sure there will be an error of some sort.

There were a couple errors but they didn’t look like they were related to the issue so I cleared it to see if
I could get them to come up again and redid it and this is the only thing I can get to show up.

Seems almost like there might be a bug some where. I have the pagination element connected to that data source and when i go through the pages the data just randomly shows up but is doesn’t show up with pagination. It only shows the first 200 items.

Hmm, I’m not sure, I’d probably need to debug this in the project myself, seems like it’s a more tedious issue.

Ok. Might have to schedule a call with you soon.

2 Likes

I’d be throwing some console.logs in the parseLotNumber variable and sortedByLots variable to see if you’re getting the result there you expect. Just by a look and without being able to see your data I’m gonna say that’s where the issue is.

If you can provide some dummy data of what’s being sorted could test it out myself

1 Like

Ok. I’ll see if I can do that.

What I’m trying to do is sort a text column alphabetic and numerical so a, b, c, 1, 1a, 1b and so on. The sorting works like it’s suppose the issue is when I try to paginate it.

Ah yea pagination would be hard with this, there’s a couple of ways I’d go about it. But they’d involve custom pagination and depends on how much data you’re using.

If you’re bringing in all the data and then I’d say do custom pagination on the front end.

If you only want to bring in the data you can see, I can see you’re using supabase. I’d be making a database function to deal with it or an edge function.

As Boberto said at this point without actually having a play around in your editor it gets hard to give advice. I’ve never spoken to Boberto outside weweb forums but from what I’ve seen I’d be confident he could help you set this up if you get stuck.

2 Likes