Nativescript: Parents binding in ListView item templates is not working until ListView is refreshed.

Created on 9 Nov 2017  路  4Comments  路  Source: NativeScript/NativeScript

Tell us about the problem

Hello guys I have a quick question I searched forums but couldnt find answer
How can I display my observable in parents if I have 2 or 3 of them
like this:

<Button text="{{ $parents['RadListView'].name + " "+ "$parents['RadListView'].surname" ]] }}" />

This above doesnt works or only gives me one item but what if I want two of them or tree displayed ????

Which platform(s) does your issue occur on?

iOS/Android/Both

Please provide the following version numbers that your issue occurs with:

  • CLI: 3.2.0


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

backlog bug medium

All 4 comments

@markomiljkovic

There are a number of syntax errors in the your Button XML line.
You have double quotes for your second binding and also some closing brackets at the end that are not needed.

Here is the refactored code that will work

<Button text="{{ $parents['RadListView'].name + '  '+ $parents['RadListView'].surname }}" />

Demo application demonstrating the above syntax can be found here.

Meanwhile, it appears that you might have to manually refresh the list view to update all parents binding in the item templates.

Logging this one as a bug - steps to reproduce use the linked application and
remove the manual refresh of the list. As a result, the binding will appear only for the few first items or only after the list is scrolled.

thank you very much its working :)

Reproducible with tns-core-modules@next

Was this page helpful?
0 / 5 - 0 ratings