Apple
December 10, 2022, 1:59am
1
Wappler 5.3.0
Assume a server connect:
[
{
"name": "George",
}
]
Assume a table with data repeat:
<tbody is="dmx-repeat" dmx-generator="bs5table" dmx-bind:repeat="sc_test.data" id="tableRepeat1">
<tr>
<td dmx-text="name"></td>
</tr>
</tbody>
If I trigger a server connect reload and the server action returns this instead, the dmx-text="name"
is not cleared:
[
{
"error": "Some error"
}
]
(assume a HTTP 200 OK status code)
The table continues showing the name "George" even though the property "name" is no longer present in the server connect data object
Teodor
December 10, 2022, 7:13am
2
Have you tried adding a key to your repeat region?
Apple
December 10, 2022, 7:22am
3
Could you please clarify?
Btw, the data in the Server Action comes from an API Action, I could workaround and use a Repeat step to iterate over api.data
and use Set Value for all possible fields (e.g.: Set Value name = {{ name || null }}
), but it doesn’t look very pretty, a lot of fields might be present
Teodor
December 10, 2022, 7:24am
4
Select your repeat region in app structure and pick a dynamic value for the key option.
Apple
December 10, 2022, 7:25am
5
This worked, thanks
Do you still consider this a bug report? I’ll leave up to you
Teodor
December 10, 2022, 7:27am
6
No, the data won’t be updated when there’s no key added, that’s by design.
Apple
December 30, 2022, 12:47pm
7
Huh, not sure what’s wrong here, but your suggestion is no longer working. Maybe some update (“optimization”) on dmx-repeat “broke” it?
How can I solve this problem again? Refer to the initial post
Edit: Ended up working around by prepending $value.
to the variable inside dmx-text
bpj
December 30, 2022, 1:58pm
8
What’s the property’s name? If you have to prepend $value it probably clashes with a data property of the repeater itself
Apple
December 30, 2022, 2:03pm
9
Hi bpj,
In the example of the 1st post, this would be $value.name
instead of just name
[
{
"name": "George",
}
]
The problem was that if name
was missing from the server connect response, it would still show the old data instead of emptying it:
[
{
"error": "Some error"
}
]
To workaround, I had to use $value.name
which would evaluate to undefined
instead of George
(as previous SC data)
bpj
December 30, 2022, 3:21pm
10
Is that even when you defined the key of the repeat?
I usually define the key and then use .default('-')
to show a - when no value is present
Apple
December 30, 2022, 4:30pm
11
Yes, even when the repeater key was defined
Also tried using .default, but it didn’t make a difference as the old value was still being kept if the newer one was undefined
patrick
November 12, 2024, 2:12pm
14
You can force a rerender by adding the rerender
attribute to the repeater.
1 Like
Apple
November 12, 2024, 2:59pm
15
That works, thanks. Is it a bug though? Why does it work if I prefix the variables with $value.
? Is it getting rid of some optimization that's equally achievable by using the rerender
attribute?
patrick
November 12, 2024, 3:27pm
16
You can test if perhaps the following update fixes it for repeater without rerender: dmxAppConnect.zip (119.1 KB)
The rerender will always recreate all children of the repeat and can fix many issues but has some performance impact.
Apple
November 12, 2024, 3:32pm
17
It didn't fix, but it's ok, I can use the rerender attribute