Dependency Cycle in new Table pagination

Hi all,

I'm creating an app with Server Side Limit Offset Based pagination in the new Table component. The datasource of the table is linked to a GetUsers query {{ GetUsers.data.items }}. The pagination total row count is also linked to the same query {{ GetUsers.data.nrOfItems }}.

The query itself uses the table pagination currentPage and pageSize parameters: users/{{usersTable.pagination.currentPage + 1}}/{{usersTable.pagination.pageSize}}?searchString={{ searchString.value }}

The query runs automatically when the inputs change, and when I first start the app I get an error saying: "Dependency Cycle Found: GetUsers -> GetUsers.query -> usersTable.pagination -> usersTable._currentPage -> usersTable._limitOffsetRowCount -> GetUsers.data -> GetUsers.query"

I removed the pagination parameter for debugging purposes and then I don't get that error. So it seems that this is why, but of course I need to know the currentpage to be able to paginate correctly.

3 Likes

Hi @ArnVanhoutte! Thanks for writing in. It seems there's an unintentional dependency cycle with your GetUsers query, since it holds information for both your total row count and your data.

Behind the scenes, currentPage is dependent on the total row count (limitOffsetRowCount) to make sure that your end users don't reach a page that doesn't exist in your server-paginated table. Currently, this creates a dependency cycle between items and total row count.

If you split up {{ GetUsers.data.nrOfItems }} and {{ GetUsers.data.items }} into separate queries, e.g. getUsers and getTotalNumberOfUsers, this should remove the dependency cycle since it separates the two concepts.

Please let me know if this is helpful!

1 Like

Hello,

For efficiency reasons we couldn't really split up the REST API Query in 2 queries. I have managed to "fix" it by setting the {{ GetUsers.data.nrOfItems }} param in a temporary state, and then using that state value in the Table Pagination settings. This gets rid of the error but it feels a bit iffy to me. It'd be nice if the new Table pagination would have a workaround build-in to prevent these dependency errors.

Hi @ArnVanhoutte Thanks for sharing your table feedback & current fix! I'll share this feedback internally :pray:

Hello @Tess,
Do you have any update on this issue ?
I have the same exact problem but the workaround doesn't work. I have this :

Like @ArnVanhoutte, i have one query that gets the elements and the number they are to enable server side pagination

Not yet, @Defteye :confused: I'll post back here when we're able to address this in the product

Had to do @ArnVanhoutte work around (thanks by the way!) but it feels way too hacky. I think it is a pretty common use case to have one query that gives you the number of elements and the elements too. I have seen it for years. With the previous table it worked perfectly.

Please keep us updated about this!

Thanks!

@Tess @AnnaW I am also experiencing this issue with no good and only highly inefficient workarounds. I can basically not use server side pagination any longer right now.

Please fix this asap.

Same here. A fix is highly appreciated.

Hi all, we released a fix this morning that should remove the dependency cycle when total row count & data are returned in the same query. In addition, a few weeks ago we released an onChangePage event handler if you wish to trigger queries when a user changes the current page of the table.

Please update in the thread if you continue having any related issues, thanks again for your feedback!

1 Like