eakoriakin / ionic-selectable

Ionic Selectable is an Ionic versatile and highly customizable component that serves as a replacement to Ionic Select, and allows to search items, including async search, create items, customize the layout with templates and much more. It provides an intuitive API and is easy to set up and use.
MIT License
549 stars 125 forks source link

Searchbar doesn't work #357

Open DadoGit00 opened 3 years ago

DadoGit00 commented 3 years ago

Hi, my selectable works, i can view every element correctly. Everything works fine except for the attribute [canSearch]="true" which doesn't make appear the searchbar. Version: 5.0.0

edy-ap commented 2 years ago

can you provide more information?, please.

Karen1240 commented 2 years ago

Hi, I am having the same problem, using v5. Using the selectable, the list of elements can be displayed. However, when added [canSearch]="true", searchbar was not displayed. May i know if canSearch currently can be used in v5?

Updated (solution for me that works) : I am using ionic selectable v4 in ionic 5.

Dan890 commented 2 years ago

I have same issue on ionic 5

shseah601 commented 2 years ago

My temporary solution for searchbar is to manually implement the searchbar in header template and search function since the component has no search method.

<ng-template ionicSelectableHeaderTemplate>
    <ion-row class="ion-no-padding">
      <ion-col class="ion-no-padding" size="12">
        <ion-toolbar>
          <ion-buttons [slot]="ionicSelectableComponent.closeButtonSlot">
            <ion-button (click)="ionicSelectableComponent.close()">
              {{ionicSelectableComponent.closeButtonText}}
            </ion-button>
          </ion-buttons>
          <ion-title>
            {{ionicSelectableComponent.titleText}}
          </ion-title>
        </ion-toolbar>
      </ion-col>

      <ion-col class="ion-no-padding" size="12">
        <ion-card>
          <ion-card-content class="ion-no-padding">
            <ion-item lines="none">
              <ion-icon slot="start" name="search-outline"></ion-icon>
              <ion-input (ionInput)="itemSearch($event)"></ion-input>
            </ion-item>
          </ion-card-content>
        </ion-card>
      </ion-col>
    </ion-row>  
  </ng-template>

You will need to use template variable ionicSelectableComponent.

The component does not have label, but with different name called titleText.

Hope this helps someone that tries to use searchbar. The search function can refer to Search items asynchronously.