Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
764 views
in Technique[技术] by (71.8m points)

angular - Clarity datagrid built-in filter is not working

I have a component template defined below:

<div class="flex-fill flex-container flex-column default-padding">
  <clr-datagrid class="flex-fill" [clrDgSingleSelected]="selectedItem | async" (clrDgSingleSelectedChange)="setSelectedItem($event)" [clrDgLoading]="loadingInProgress | async">
    <clr-dg-action-bar class="flex-row justify-content-space-between">
      <div class="flex-auto ">
        <div class="btn-group">
          <button (click)="setIsCreateDialogOpen(true)" class="btn btn-sm btn-success" type="button">
            <clr-icon shape="add"></clr-icon>
            Test Item
          </button>
        </div>
        <div class="btn-group">
        </div>
        <div class="btn-group">
        </div>
      </div>

    </clr-dg-action-bar>

    <clr-dg-column [clrDgField]="'name'">Name</clr-dg-column>
    <clr-dg-column>Address</clr-dg-column>

    <clr-dg-row *ngFor="let item of Items | async" [clrDgItem]="item.name">
      <clr-dg-cell><a [routerLink]="item.name" queryParamsHandling="merge" [queryParams]="{a: 'A', reference: undefined}"> {{item.name}}</a></clr-dg-cell>
      <clr-dg-cell>{{item.Address}}</clr-dg-cell>
    </clr-dg-row>
    <clr-dg-footer>{{(Items | async)?.length}} Items</clr-dg-footer>
  </clr-datagrid>
</div>

I'm trying to use the [clrDgField] attribute to enable the filter. I can see the filter icon on the column but when I type something in, no filtering whatever happens. I'm using clarity design system.

I tried the same with a filer defined like:

<clr-dg-column>Name
  <clr-dg-string-filter [clrDgStringFilter]="itemFilter"></clr-dg-string-filter>
</clr-dg-column>

where itemFilter is

class ItemNameFilter implements ClrDatagridStringFilterInterface<Item> {
  accepts(item: Item, search: string): boolean {
    return item.name.toLocaleLowerCase().includes(search.toLocaleLowerCase());
  }
}

which is still not giving any result.

question from:https://stackoverflow.com/questions/65652336/clarity-datagrid-built-in-filter-is-not-working

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...