DMXzone Server Connect Support Product Page

Answered

Use two tables with foreign key

Asked 03 Mar 2016 22:53:32
1
has this question
03 Mar 2016 22:53:32 Hans Haverlach posted:
Hi I have two action files. The first one displays products in a repeat region1.
The second one only displays connected series in repeat region 2, depending on the product ID clicked.

When user clicks one product the product ID should trigger the second action file to display connected series in a repeat region2, The series data table in the database has the product ID in a foreign key field.

I can't get it to work. I setup the second action file with a POST filter. And in the server connect action executer I connect this filter to a form value from repeat region1.

Then I added a onClick event to the product names from repeat region1 to control server connect action executor to RUN the executor of the second action file.
When I try it in the browser, I see al the products (repeat region 1) but when I click no data is displayed in repeat region 2.

How do I proceed? Is there a different way? I could not find a video explaining this in combination with the use of the server connect extension.
Please advice!

Replies

Replied 04 Mar 2016 03:47:23
04 Mar 2016 03:47:23 Greta Garberini replied:
Hi,
I don't know if I understood everything you asked for. Mabe this helps?
www.dmxzone.com/go/22724/master-detail-relationship-with-dmxzone-database-connector
Replied 04 Mar 2016 10:29:48
04 Mar 2016 10:29:48 Hans Haverlach replied:
Thank you Greta. This is what I meant, and it does work "the old way" using html5 databinding datasources.
But DMX gave us the new Server Connect and promotes that we should be using Server Connect also to use as data source.

So if you try the master-detail relationship as in the video above, but now with the Server Connect as datasource, it does NOT work. Perhaps there must be a different approach.
Please DMX, can you shine your light on this??

Thank you.
Replied 04 Mar 2016 18:22:43
04 Mar 2016 18:22:43 George Petrov replied:
Well this should work in pretty much the same way with the Server Actions Executors now instead of old data sources. The Server action Executors are the new data sources for the server connect.

You should be able to filter the server actions the same way.

I will see if we can make a video about this next week, but the way is almost identical.

For smaller data you can even use a single server action that returns a hierarchical data from both queries at the same time and you can filter those client side with HTML5 Data Bindings Formatter's filter functions.

Greetings,
George
Replied 05 Mar 2016 13:00:53
05 Mar 2016 13:00:53 Hans Haverlach replied:
Hi George,
It does work pretty much the same. And I really like it that we can all do it from server connect dialogs.
I think the problem lies with the DMX behavior.
With the onClick event I have to choose for the server connect action executor. The only option there is: RUN or Abort. I chose RUN and then to run my second action executor.
But somehow it does not pick up the FORM value I set up to be used by the filter.

Then again I might be overlooking something, so I really looking forward to see your video. I'm sure it will help others too! Keep up the good work!

Thank you.
Replied 08 Mar 2016 10:50:00
08 Mar 2016 10:50:00 Hans Haverlach replied:
Okay,
I got it to work! I made it to complicated, with extra behaviour events etc... and used a POST value instead of GET. And a tricky thing: ALWAYS save your action files, after every change. I tend to forget that, and unless you click somewhere else in the Server Connect window, it does not remind you your last changes were not saved.
(maybe a auto save function will work great??)


Setup for anyone interested:
repeat region with products. Underneath a hidden INPUT in a detail region with the foreign key value.
The second action file executor FILTERS with FORM value from this INPUT. (with a REFRESH when INPUT changes). All very simple, and works great.

Hans


Reply to this topic