I am trying to implement {N} telerik's UI RadListView. Here is their getting started guide, which I followed as a reference.
I have setup the following XML layout :
list.xml
<StackLayout loaded="loaded" xmlns:lv="nativescript-telerik-ui/listview" xmlns="http://www.nativescript.org/tns.xsd">
<lv:RadListView items="{{ rankingsArray }}">
<lv:RadListView.listViewLayout>
<lv:ListViewLinearLayout scrollDirection="vertical"/>
</lv:RadListView.listViewLayout>
</lv:RadListView>
<lv:RadListView.itemTemplate>
<StackLayout orientation="horizontal" horizontalAlignment="center" class="sl_ranking">
<Label text="{{ name }}"></Label>
</StackLayout>
</lv:RadListView.itemTemplate>
</StackLayout>
Basically I am binding the list view to a rankingsArray
containing child elements which have a name
property.
In fact here is how I do the binding :
list.js var HashtagList = require("~/viewmodels/HashtagsList");
exports.loaded = function(args){
var hashtagList = new HashtagList();
var profile = args.object;
profile.bindingContext = hashtagList;
}
HashtagList is class defined as :
var Hashtag = require("~/classes/Hashtag");
var ObservableModule = require("data/observable-array");
class HashtagList{
constructor(){
}
get rankingsArray(){
if(!this._list){
this._list = new ObservableModule.ObservableArray();
this._list.push(new Hashtag("#pizzawithfriends"));
this._list.push(new Hashtag("#funky"));
}
return this._list;
}
}
module.exports = HashtagList;
As you can see any HashtagList
object has a public rankingsArray
property which returns an observable array
of Hashtag
objects.
Here is the definition of the Hashtag
object:
hashtag.js
"use strict";
var Hashtag = function(name){
var _name = name;
//====== NAME GETTER & SETTER ======//
Object.defineProperty(this,"name",{
get : function(){
return _name;
},
set : function(value){
_name = value;
}
})
}
module.exports = Hashtag;
The problem is that for some reason I get the following error :
Binding: Property: 'name' is invalid or does not exist. SourceProperty: 'name'
and nothing appears on the screen.
This is weird because if I can access HashtagList.rankingsArray.getItem(0).name
without problems.
What is causing this behavior?
Turns out I closed the
label
tag in the wrong way...