编辑:,我已经发布了让RadListView与分组函数这里一起工作的高级版本。这里的问题是如何使RadListView以其基本形式工作。
我已经离开Nativescript几个月了,现在我正在尝试将一个多级列表(包含类别、每个类别中的项目,以及能够用tap隐藏和显示类别的用户)放在一起。从讨论这里中我看到*ngFor不是实现多级列表的稳定方法(尽管它是最简单的!)
所以现在我尝试使用职业ui列表视图,但是文档已经有了几个月的历史,并且使用了术语"RadListView“。
RadListView还存在吗?在Nativescript角中做两到三个级别列表的最佳文档是什么?
详细信息,以防万一:
因此,我现在正在尝试使用RadListView来完成这个任务,但我不清楚RadListView是否还存在。Nativescript pro ui的市场列表显示,旧的支持ui已经被废弃,现在每一项pro ui都必须单独下载(链接)。
它列出了一个专用ui“npm上市”的npm上市,它使用了"ListView“这个术语。但是,当您单击npm列表中的任何文档/示例代码链接时,它们都会使用术语"RadListView“(旧的公式)。
我不能让RadListView工作。即使是最简单的例子(几个月前也起作用了),如果我在组件html中使用RadListView,屏幕也是空白的。
例如,我正在尝试做一个多级列表。看起来RadListView中的“分组”函数是(唯一的?)做这个的方法。我从这里中剪切和粘贴了代码,但是它不工作--空白屏幕上有"RadListView“,没有数据只有"ListView”。
示例:
ts:
import { ListViewEventData, LoadOnDemandListViewEventData } from "nativescript-ui-listview";
import { RadListViewComponent } from "nativescript-ui-listview/angular";
export class SampleComponent implements OnInit {
public arrayItems = [
{category:'person', name: 'jim', description: 'a very
nice person'},
{category:'jungle animal', name: 'lion', description:
'king of the jungle'}
]
private _myGroupingFunc: (item: any) => any;
constructor (){
this.myGroupingFunc = (item: arrayItems) => {
return item.category;
};
}
ngOnInit(): void {
}
get myGroupingFunc(): (item: any) => any {
return this._myGroupingFunc;
}
set myGroupingFunc(value: (item: any) => any) {
this._myGroupingFunc = value;
}
}...html:
<StackLayout>
<ListView [items]="arrayItems" enableCollapsibleGroups="true" [groupingFunction]="myGroupingFunc" >
<ng-template tkListItemTemplate let-arrayItem="item" >
<StackLayout>
<Label [text]="arrayItem.name"></Label>
<Label [text]="arrayItem.description"></Label>
</StackLayout>
</ng-template>
</ListView>
</StackLayout>通过从这里复制的这段代码,不会出现任何条目(只是ListView中没有任何内容的行)。如果我说的是"RadListView“而不是"ListView",屏幕就完全是空白的。如果有人已经更新了这个操作的代码,我肯定会很感激。
发布于 2018-12-11 19:43:12
感谢伊恩MacDonald的帮助。RadListView确实仍然是列表视图的Nativescript版本。对我来说是这样的:
$ tns plugin add nativescript-ui-listview
$ npm i
$ tns update //don't know why/what was out of date, but features like the grouping function did not work for me until I ran this.coolComponent.module.ts:(如果使用延迟加载,我只能通过将模块直接导入组件模块来使RadListView工作)
import { NativeScriptUIListViewModule } from "nativescript-ui-listview/angular";
...
@ngModule({
imports: [
...
NativeScriptUIListViewModule,
]
...coolComponent.html:
<GridLayout>
<RadListView [items]="cats" >
<ng-template tkListItemTemplate let-cat="item">
<StackLayout>
<Label [text]="cat"></Label>
</StackLayout>
</ng-template>
</RadListView>
</GridLayout>coolComponent.ts:
import { Component } from "@angular/core";
import { ListViewEventData, RadListView } from "nativescript-ui-listview";
...
export class CoolComponent {
public cats = ['tiger', 'lion', 'puma']
constructor(){
}
} https://stackoverflow.com/questions/53712148
复制相似问题