Great job ! I like listview function using multiple template. Isn't it got empty template when data items is empty?
Thank you for your interest in NativeScript!
You can create your own templates and implement your own logic that can check if the item passed is fulfilling your criteria (e.g. empty item).
e.g. the source array has one "empty" item (in this case no age property specified)
this.myItems = [{ age: 34 }, { age: 25 }, {}, { age: 37 }];
then using the itemTemplateSelector callback we can implement our custom logic
export function selectItemTemplate(item: any, index: number, items: Array<any>) {
return item.age ? "base" : "empty";
}
and from that point and item that does not have an age property will load the "empty" template
<template key="empty">
<!-- your empty template follows here -->
<StackLayout></StackLayout>
</template>
The same principle can be applied for both RadListView and ListView.
@NickIliev - this isn't the same thing. Your dataset (this.myItems) is not empty. What we're looking for is something similar to this.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
@NickIliev - this isn't the same thing. Your dataset (this.myItems) is not empty. What we're looking for is something similar to this.