DMXzone App Connect Support Product Page


sorting by buttons

Asked 19 Apr 2018 12:37:08
has this question
19 Apr 2018 12:37:08 dougie coulter posted:
I want to add an option to sort by a particular column as per this video

I've followed the video up to the point where it refers to the old action executor method and (assuming this was the correct way to go about it)would like to know how to complete the task using app connect.



Replied 20 Apr 2018 06:47:17
20 Apr 2018 06:47:17 Teodor Kuduschiev replied:
Hello Dougie,
Are you using a repeat region created from your query, or are you using the Data View component to do this?
Using Data View allows you to add filter options to your data:
Replied 20 Apr 2018 16:05:07
20 Apr 2018 16:05:07 dougie coulter replied:
Hi Teodor
repeat region, I'm nearly done with the project and therefore already too heavily committed (and overspent) to change.


Replied 23 Apr 2018 06:37:39
23 Apr 2018 06:37:39 Teodor Kuduschiev replied:
Hi Dougie,
You need to create a get variable in your server action. It will be used for sorting:

Then in sort order dialog add the column you'd like to sort by twice - once for ascending order, and then for descending order. Use the conditions there to make it sort depending on the get variable value - sort ASC when the get variable value == 'asc' and sort DESC when get variable value == 'desc'

Insert your repeat region with the data on the page, add the two buttons for sorting and select: dynamic events > mouse > click and then for the action select your server action, and enter the get variable value:

Replied 24 Apr 2018 19:29:07
24 Apr 2018 19:29:07 dougie coulter replied:
Thank you very much Teodor

That's a big help.

Replied 24 Apr 2018 21:57:38
24 Apr 2018 21:57:38 dougie coulter replied:
Ok, maybe I spoke too soon...

re the last step
the left half of your image doesn't show what you have selected, logic suggests that since it's defining an mouse click action that this final step (click) is addressing the button. However, when I select the button, I'm presented with something different. see here

Also, I've played around selecting various attributes and the options for their properties and I can't see anywhere in app connect that lets me access the variable created earlier. Does it have to be entered manually?

Replied 24 Apr 2018 22:28:26
24 Apr 2018 22:28:26 dougie coulter replied:
Here's an interesting twist...

If I select the button and tell it to reload the form and then in the input parameters - filter - select a different column and in the sort box simply enter 'desc' It works perfectly, or sort of...what happens is the repeat region reorders itself as expected but in around 2 seconds, it reverts back to its previous state.

As far as I can see, this method is completely bypassing the variable but does exactly what's required. If I could only figure out why it only lasts for a second or two. any ideas?

Replied 25 Apr 2018 06:18:45
25 Apr 2018 06:18:45 Teodor Kuduschiev replied:
Hello Dougie,
I don't understand what exactly are you doing from your explanation.
All you need to do is to select the button and select: dynamic events > mouse > click and then for the action select your server action, and enter the get variable value as on my last screenshot ... not sure what forms reloads are you referring to?
Replied 25 Apr 2018 09:06:58
25 Apr 2018 09:06:58 dougie coulter replied:
The main issue I have following your last step - when I select the button and the click the icon to assign an action, I'm presented with something that looks quite different from your screenshot. I included a link to my screenshot in the earlier post so you could see this.

However, it looks like the action attached to your button is serverconnect1.load({sortDir:'asc'}) which I entered manually and this works but only momentarily. I've removed the security from the page I'm working so you can take a look.
click the button and you'll see what I mean


Replied 25 Apr 2018 09:45:36
25 Apr 2018 09:45:36 Teodor Kuduschiev replied:
My screenshot shows absolutely the same as yours ... i see no differences:

There are some things i see in the code that must not be there:
dmx-param:sort="'asc'" dmx-param:sortdir="'asc'"


  <dmx-serverconnect id="serverconnect1" url="dmxConnect/api/basicdiary/diary-01.php" dmx-param:filter="[0].FUNCDATE" dmx-param:sort="'asc'" dmx-param:sortdir="'asc'"></dmx-serverconnect>

this should fix the issue.
And please use the UI (As shown in the screenshot) do not add code by hands as you might mess the things up.

Replied 25 Apr 2018 10:25:55
25 Apr 2018 10:25:55 Teodor Kuduschiev replied:
Another issue i see, which makes no sense.
You are filtering the query with a value from the same query? What is the point of doing this?


What happens here is:
1. your query loads
2. your query then filters itself, when the results are aloaded
3. your query reloads

This makes no sense at all ... you don't filter the query with a value from the same query. So remove this filter value, it should not be there also.
Replied 25 Apr 2018 12:54:07
25 Apr 2018 12:54:07 dougie coulter replied:
Ok thanks, removing both of these has done the trick.

Sorry for "filtering the query with a value from the same query" but in the absence of anything that could even loosely be considered "documentation," I set about exploring the extensions, trying things to see what they do. Seemed like a reasonable way to spend the 4 days I did waiting on an answer to a question that would surely be covered in the "quick-start guide" if there was one. Obviously I was careless not to experiment on a duplicate of the file which would have made your job less frustrating, for that I'm sorry. I feel your pain and promise I'd far rather RTFM than bother others with my woes.

Much regards


Reply to this topic