Data view table sortable headers

Hello,
I have a dataview generated bootstrap table, and now I am trying to make the column headers sortable.

It works when connecting the sort and dir to the server connect element.

But I thought by using a data view for the table it can be sorted without the nead to make another call to the databse through the server connect.

Then what is the benefit of the data view when sorting can only be done on the server connect?

I hope I can use the data view and only have to get all the records once and then order and sort them on the front end without the need of another database call.

I hope I made myself clear.

Can someone point me in the right direction?
Thanks!!

I'd be interested in learning if it were possible simply to sort on the user's end, like you are hoping for.

But, as far as I know, sorting always goes back to the database when using the bootstrap sort.

So, does it mean that when you want to be able to sort the table like this, there is no use for a data-view?

Is there somewhere a clear explanation/tutorial about data views and other data display components so I get a clear understanding over when to use what?

You can create a sortable table with the data view. In the Bootstrap Table Generator just choose the table source to be your data view and setup the sorting as you usually do with a regular db query.

1 Like

Teodor, I have set my table to the data view and added sortable headers.

But when I click a header and watch the network tab I see the a call to the server connect is made on every click:
image

Did I miss anything?

The server action will refresh if you are using the sort/dir query params for it. Check if your server action has parameters and if these two query params are used as values there.

Yes they do:
image

But only because the sorting wasn't working untill I added them here.

There is no option to add them to the data view:

image

You need to remove the sorting params from the server action and simply add them to the data view (under dynamic attributes):

Yes! Thats the way.

So happy this can be done. Thnx Teodor

1 Like