Table sorting bug?

Followed the tutorial for table sorting.

Ran Bootstrap 5 generator and selected the query manager i created for sort and direction.

however, clicking the column headers or the little arrows changed nothing. For the click event I had to add the server connect .load so that clicking the header would sort the table.

Is that normal? The tutorial didn’t mention it.

image

No, that is not normal and should not be necessary. Can you show your query and table settings.

query manager:
image

query properties:
image

Posting one table header as example:
<th class="sorting" dmx-on:click="myticketsSorting1.set('sort','id');myticketsSorting1.set('dir',myticketsSorting1.data.dir == 'desc' ? 'asc' : 'desc')" dmx-class:sorting_asc="myticketsSorting1.data.sort=='id' && myticketsSorting1.data.dir == 'asc'" dmx-class:sorting_desc="myticketsSorting1.data.sort=='id' && myticketsSorting1.data.dir == 'desc'">Ticket</th>

table body:
<tbody is="dmx-repeat" dmx-generator="bs5table" dmx-bind:repeat="getAgentsTickets.data.query" id="tableRepeat3" dmx-state="myticketsSorting1" dmx-sort="sort" dmx-order="dir">

Database Query options and page server connect settings.

Which query options? In the server side?

that’s actually the wrong query above. Here’s the actual query.
image

server connect properties:

image

Setup of query builder showing the sql query

I see you have no autoload set. Is the action called from an event?

It’s call on click of a button.


That is probably why the refresh is needed. Could you try to use the new dynamic autoload attribute so it autoloads when when the required condition is met or use a variable as toggle flag if necessary.

Dynamic auto load? I see an checkbox for “No Auto Load”

it is using a variable toggle. Here’s the click event for the button, calls the load event for the server connect and toggles the variable.

No checkbox because it’s a dynamic attribute

interesting… not an option for that server connect.

image

I changed the server connect, no auto load is now NOT checked. Table sorting seems to work.
image

I’m not sure if it’s a bug, needing the server connect to auto load, or it’s intended for a reason. When I put in our production data I’m going to have two queries that return 10s of thousands of records and it’s going to be slow. Not autoloading the agent’s tickets would be very beneficial.

Looking at my other options.

Autoload can be dynamic so you can apply it conditionally so it does not autoload initially but does on click. Easiest way is probable set a variable to 0, toggle it to 1 in click event and set the dynamic attribute autoload to variable == 1

EDIT: dynamic setting of no autoload was introduced in the last wappler update, make sure you have upgraded to latest version

and it might work great but I didn’t have that option on the server connect like you did. I changed my alltickets query to use conditional and add the agent id when it’s sent.

Sounds like you are not on the latest version of wappler? It was only introduced in the last update

updated, it’s there now. But i’ve already changed to use 1 query and conditionals. I will try to add the sorting back as it will be needed once we have production data loaded.