Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 如何在素数树表中添加过滤函数_Angular_Primeng_Primeng Treetable - Fatal编程技术网

Angular 如何在素数树表中添加过滤函数

Angular 如何在素数树表中添加过滤函数,angular,primeng,primeng-treetable,Angular,Primeng,Primeng Treetable,我正在尝试向素数树表添加一个过滤函数。下面的代码显示了我的当前情况 <div class="content-section introduction"> <div> <span class="feature-title">Katerra</span> <span>Cost Master</span> </div> </div> <div clas

我正在尝试向素数树表添加一个过滤函数。下面的代码显示了我的当前情况

<div class="content-section introduction">
    <div>
        <span class="feature-title">Katerra</span>
        <span>Cost Master</span>
    </div>
</div>

<div class="content-section implementation">
    <p-growl [value]="msgs"></p-growl>

<input [(ngModel)]="searchText" placeholder="search text goes here">
<p-treeTable [value]="files6 | filter:searchText" selectionMode="single" [(selection)]="selectedFile2" [style]="{'margin-top':'50px'}" [contextMenu]="cm">
    <p-header>Context Menu</p-header>
    <p-column field="name" header="Division"></p-column>
    <p-column field="size" header="Code"></p-column>
</p-treeTable>
<p-contextMenu #cm [model]="items"></p-contextMenu>

任何建议都很好

这基本上意味着您没有定义管道过滤器。 要创建管道,请运行以下命令:
$ng g pipe filter
现在,如果要执行基本筛选,请将此代码添加到生成的管道中:

// I am unsure of the name of the generated pipe change it if needed 
export class FilterPipe implements PipeTransform {
    transform(items: any[], searchText: string): any {
        return items.filter(item => item.indexOf(searchText) !== -1);
    }
}

到目前为止,树表中还没有过滤器功能 GitHub配置文件上有问题注册,很快就会实现。您可以检查状态

因此,基本上,您正在尝试对priming属性使用过滤器,这显然会引发错误。因为该属性的筛选器是未知属性


您可以使用普通的ng repat来显示表格,也可以使用过滤器选项,否则需要等待此功能启用

你好,梅尔基亚,谢谢你的回复。我根据您的建议创建了一个筛选器,但错误仍然存在。新版本具有内置筛选器功能:
ERROR Error: Uncaught (in promise): Error: Template parse errors:
The pipe 'filter' could not be found ("

<input [(ngModel)]="searchText" placeholder="search text goes here">
<p-treeTable [ERROR ->][value]="files6 | filter:searchText" selectionMode="single" [(selection)]="selectedFile2" [style]="{'"): ng:///TreeTableDemoModule/TreeTableDemo.html@11:13
Error: Template parse errors:
The pipe 'filter' could not be found ("
// I am unsure of the name of the generated pipe change it if needed 
export class FilterPipe implements PipeTransform {
    transform(items: any[], searchText: string): any {
        return items.filter(item => item.indexOf(searchText) !== -1);
    }
}