Dmx-text in dmx-repeat persists even if SC property no longer exists

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

Have you tried adding a key to your repeat region?

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

Select your repeat region in app structure and pick a dynamic value for the key option.

This worked, thanks :blush:

Do you still consider this a bug report? I’ll leave up to you

No, the data won’t be updated when there’s no key added, that’s by design.

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

What’s the property’s name? If you have to prepend $value it probably clashes with a data property of the repeater itself

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)

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

Yes, even when the repeater key was defined :frowning:

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

Hello,

This bug still persists

You can force a rerender by adding the rerender attribute to the repeater.

1 Like

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?

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.

It didn't fix, but it's ok, I can use the rerender attribute