swf
February 4, 2019, 8:22am
1
When I use dmx-show to show/hide content from a datasource, the code is shortly shown on the page.
For example I have no records in the news dataview, but “No records in database.” shows up for a short time and then disappears. I’m using this code.
<div class="row py-4" dmx-show="!dvNews.data.hasItems()">
<div class="col-md-9">
<p>No records in database.</p>
</div>
</div>
Looks like the DMXZone code is executed after the html code. How can I improve this?
swf
February 4, 2019, 9:42am
3
Thanks Ben, yes, that doesn’t fix the problem. The html code is written before the code is being executed.
George
February 4, 2019, 10:48am
4
do you have a live example that we can check?
swf
February 4, 2019, 11:39am
5
Can I send you the link as a pm?
mrbdrm
February 4, 2019, 12:16pm
6
change it to something like this
dmx-hide="dvNews.data.hasItems() || dvNews.state.executing"
1 Like
This works. I had given up on this thinking there was no option. Thanks.
swf
February 5, 2019, 7:46am
9
btw what is the correct syntax?
dmx-show=“dvDokumente.items”
or
dmx-show=“dvDokumente.data.hasItems()”
?
George
February 5, 2019, 8:04am
10
Well it seems like you are just checking the wrong data…
You should just pick the expression containing the data that you are usually going to repeat, like:
add Show on:
In the formatter selection conditional / hasItems
final expression:
swf
February 5, 2019, 8:10am
11
What about the data in the dataview? Can’t I use them to show/hide? As I am filtering the data view, it doesn’t make sense for me to show hide the server connect
George
February 5, 2019, 8:27am
12
Yes indeed you can show/hide on dataview data as well.
With data view it is even easier as you can check directly the items under it.
so you can use:
dmx-show="dataviewName.data.hasItems()"
or
dmx-show="dataviewName.items > 0"
or with specific number of items:
dmx-show="dataviewName.items > 5"
swf
February 5, 2019, 8:29am
13
Do I have to use
dmx-show="dataviewName.items > 0"
or is this also ok:
dmx-show="dataviewName.items"
swf
February 5, 2019, 8:30am
14
Back to the main problem of the post, do you have a solution for it?
George
February 5, 2019, 8:36am
15
yes both should work.
I checked your page you send me on PM - and can’t see what is not working. You have one record so everything shows as it should
swf
February 5, 2019, 8:38am
16
When you (re)load the page you can see the placeholdertext for no records:
“Es wurde kein Datensatz gefunden.”
That’s the problem
George
February 5, 2019, 9:08am
17
oh that - is just a flash in the beginning - because you don’t have the data yet - and initially the region is visible. So just make sure that is initially hidden with css set it’s display to none - that is all
and when the data is loaded and there is no data - it will be made visible by dmx-show
swf
February 5, 2019, 9:14am
18
So I have to toggle an additional class with display:block to the region to show it if necessary?
George
February 5, 2019, 9:17am
19
No that is what dmx-show will do later - you just have to make sure that initially - the browser dosn’t show the element - by having it in the css with display none. Make a class for it or just add inline style:
style="display:none"
George
February 5, 2019, 9:25am
20
and actually for the most easiest solution - just apply the page loader - that waits will all data is loaded first:
So they you will avoid any flashing