DMXzone App Connect Support Product Page

Answered

how do I change offset on page load?

Asked 14 Jun 2018 13:10:36
1
has this question
14 Jun 2018 13:10:36 Bruce Wilkie posted:
Hi there

I'm wanting to change the offset of a paged query when the page loads.
Eventually I'm wanting to set it to the value contained in the querystring, but for now I just want to change it to a fixed value.
I can do it with a link on the page as follows:

dmx-on:click="currentOffset.setValue(10)"

This moves the results I'm showing onto the second page, since I have set a limit of 10 in the Server Connect Prperties box.

What I want to do is to move to the second page as soon as it loads.

I've tried using onload and ready in the body tag as follows:

dmx-on:load="currentOffset.setValue(10)"
dmx-on:ready="currentOffset.setValue(10)"

(I can't show you the full body tag with the above included since this form is blocking me from typing code again)

But neither of those has the desired effect.

I suspect you're going to ask why I want to do this, so I'll say now.

I've got a Details page, filtered by url parameter that I link to from this page, and I'm wanting to put a back button in that will return me to this page with the correct offset. Rather than returning me to the first page. I've already passed the offset to the details page using another url parameter, and I'm passing it back to this page using that same url parameter.

So, all I need to do is set the offset upon arriving back at this page.

Firstly I want to do it with the fixed value in my example above (10), and then I'll go to the next step and do it with the url parameter.

Hope you can help

Bruce

Replies

Replied 14 Jun 2018 13:42:13
14 Jun 2018 13:42:13 Teodor Kuduschiev replied:
Hello Bruce,
You can do this the same as with query params ... just select your server action, and under input parameters enter 10 for offset.
The same way as you will later just bind your query.param there.
Replied 14 Jun 2018 14:01:42
14 Jun 2018 14:01:42 Bruce Wilkie replied:
Thanks Teodor

Have tried that now and it worked ok for a fixed value, but it's not working when I set it to a variable unfortunately.

I've tried the following, but none working:

query.offset
{{query.offset}}
{{$_GET.offset}}

(the last one seems to be the default value when I add the paged query)

The url for the page when I'm testing is: www.website.com/news.htm?offset=10

Is there something else I've missed do you think?

Bruce

Replied 14 Jun 2018 14:04:43
14 Jun 2018 14:04:43 Teodor Kuduschiev replied:
Well, have you first defined a query param in App Connect?
Have you used the dynamic data picker button to select the dynamic data - don't just try writing random stuff there?
Replied 14 Jun 2018 14:13:07
14 Jun 2018 14:13:07 Bruce Wilkie replied:
OK, I'll give that a go. How do I add a query param?
Replied 14 Jun 2018 14:13:36
14 Jun 2018 14:13:36 Bruce Wilkie replied:
Is it adding a variable from the menu when I right-click App?
Replied 14 Jun 2018 14:14:53
14 Jun 2018 14:14:53 Teodor Kuduschiev replied:
Not variable Bruce.
Select App root, and then click the "Query Parameters" button. Or if you are using State Management - define it there - it is the same.
Replied 14 Jun 2018 14:20:13
14 Jun 2018 14:20:13 Bruce Wilkie replied:
OK, when I select 'App' in the App Structure box, in the App Properties box below it I can see 'App Root'

When I click on this I can choose 'Body' or 'Page'

Or, when I click on 'Define Query Params' then a new window opens up called 'DMXZone App Connect Shema Editor'

This has a section called 'Query Parmas for news' and in that section is a single entry with a 3d box next to it called 'query'

Do I click on that?
Replied 14 Jun 2018 14:25:03
14 Jun 2018 14:25:03 Teodor Kuduschiev replied:
Bruce, you just need to click the define query params button and define your query parameter there!
There are no other buttons in the UI related to query parameters anyway...
prntscr.com/juy3xs
prntscr.com/juy4fy
Replied 14 Jun 2018 14:29:06
14 Jun 2018 14:29:06 Bruce Wilkie replied:
OK, done that now.

So what's the next step?
Do I go back to Server Connect and the Paged Query?
Do I still need to enter something in the 'Offset' text box there, like {{query.offset}} now?
Replied 14 Jun 2018 14:33:40
14 Jun 2018 14:33:40 Teodor Kuduschiev replied:
Just bind the query param you just created in the offset field in APP CONNECT panel, under your server connect component.
Replied 14 Jun 2018 14:34:30
14 Jun 2018 14:34:30 Teodor Kuduschiev replied:
And by the way all of this is already explained in app connect manual: www.dmxzone.com/go/32764/dmxzone-app-connect-manual/32873/keep-current-pagination-state-on-page-reload
Replied 14 Jun 2018 14:40:34
14 Jun 2018 14:40:34 Bruce Wilkie replied:
OK.

I've currently got that set to 'currentOffset.value' after following one of the videos.

So I just delete that now and replace it with the new 'offset.value' that's listed under the query databindings?

Does that mean I no longer need a variable called 'currentOffset' now?

I'm using that for my pagination buttons (previous, next etc.). Will these buttons continue to work ok?
Replied 14 Jun 2018 14:43:52
14 Jun 2018 14:43:52 Teodor Kuduschiev replied:
I don't understand all of these questions Bruce.

If you want to load the current offset value to the offset field, from the query param - just bind your query param value there!
Replied 14 Jun 2018 15:16:35
14 Jun 2018 15:16:35 Bruce Wilkie replied:
Hi Toedor

Got it working now

Thanks for your patience.

Starting to understand a little how App Connect works now

cheers
Bruce

Reply to this topic