Set Data Detail on page load

Is there a way to set the data_detail1.select on page load?

I’ve tried

<body is="dmx-app" dmx-on:load="data_detail1.select(repeat1[0].$index)">

And various combinations. I would like to load the first record so that the data detail is not empty on page load.

Hi Max,

What displays if you leave off that on-load statement? Is it blank or show last record?

Hi Max,
What if you enter a value in the value option of the data detail options?
You don’t need to use a dynamic event on load.

So when the page loads I have this screen, a repeat of results on the left and the data detail in a card on the right.

Once the page has loaded I have to manually click on a repeat row to show the data detail record...

It would be good if the first record is loaded automatically into the data detail so that it isn't empty.


If I leave out the on-load statement it behaves in the same way as above.


I've tried adding a static value in addition to the data source and key but that doesn't seem to make much difference unless I'm trying the wrong value. My data detail is currently set to:

<div class="page-sidebar bg-light" is="dmx-data-detail" id="ddContact" dmx-bind:data="contact_detail.data.contacts" key="account_id">

So entering an existing static value in the value option of the detail region does nothing?
Do you see any errors, related to this in the console?

So I’ve added

dmx-bind:value="2"

The first result has an “account_id” value of 2. No difference, still shows as blank on page load. No console errors or warnings in Wappler. Running latest version.

Ok, will check this tomorrow morning.

1 Like

I tried with a static value and it worked. There are probably other factors involved. I think it will also work with a flow - but it might mean an additional database call.

Interesting,

so this does not work…

dmx-bind:data="contact_detail.data.contacts" key="account_id" dmx-bind:value="2"

If I remove the key and keep the static value…

dmx-bind:data="contact_detail.data.contacts" dmx-bind:value="2"

It shows that record one page load, great! But because I’ve removed the key none of the other records now display.

This worked for me:
<body is="dmx-app" id="test" dmx-on:load="data_detail1.select(5)">
(to load record with id=5)
. and so did this flow, set to Auto Run:

image

2 Likes

Great, yes that works.

Is there a way though to set this as the first item returned from either the repeat or its data source (i.e- server connect?)

I won’t be able to use a static value in the .select as the ID will differ depending on permissions and results returned from SC/repeat.

I see you have in your flow example. Does it have to be run from the flow?

Ok so I seemed to have solved it…

Instead of loading dmx-on:done on the body tag, I’ve added it as a Done action on the server connect file itself. Working great now with the data detail showing the dynamic value rather than static on page load.

Thanks everyone!

1 Like

I’m trying to do the same thing but it’s not working for me. I have added a ‘Done’ event to the Server Connect but it’s not affecting the data detail.

[UPDATE]
All working. I needed to make it a number.

1 Like