Filter Drop down list component on multiple columns?

Hello,


What is the best approach to filter Drop down list component on multiple columns?
For example, I want to filter customer objects by FirstName and LastName...

Thank you,
M

3 Replies 1 reply marked as answer

PM Ponmani Murugaiyan Syncfusion Team July 1, 2020 06:44 AM UTC

Hi MM,   
  
Greetings from Syncfusion support. 
 
You can filter the multiple columns or fields in DropDownList component by using custom filtering and predicate as like below code snippet. 
 
[app.component.html] 
 
<ejs-dropdownlist  id='multiselectelement' #sample [dataSource]='data' [fields]='fields'  [placeholder]='text' [allowFiltering]='true' (filtering)='onFiltering($event)'> 
  <ng-template #itemTemplate="" let-data=""> 
    <!--set the value to itemTemplate property--> 
      <div><span class='name'>{{data.FirstName}}</span><span class ='city'>{{data.LastName}}</span></div>      
  </ng-template> 
   <ng-template #valueTemplate="" let-data=""> 
          <!--set the value to valueTemplate property--> 
          <span class='value'>{{data.FirstName}} {{data.LastName}}</span> 
      </ng-template> 
</ejs-dropdownlist> 
 
 
 
[app.component.ts] 
 
public onFiltering =  (e: FilteringEventArgs) => { 
    let query = new Query(); 
    let predicateQuery = query.where(new Predicate('FirstName', 'contains', e.text, true).or('LastName', 'contains', e.text, true)); 
    query = (e.text !== '') ? predicateQuery : query;   
    e.updateData(this.data, query); 
}; 
 
 
 
 
Kindly check with the above sample. Please get back us if you need further assistance.  
 
Regards,  
Ponmani M 


Marked as answer

MM MM July 1, 2020 06:14 PM UTC

Thank you, Ponmani M.
This is exactly the example that I needed.


PM Ponmani Murugaiyan Syncfusion Team July 2, 2020 04:17 AM UTC

Hi Maja,  

Thanks for your update.  

We have glad to hear that the provided suggestion helped you in achieving your requirement.  

Please get back to us if you need further assistance.  

Regards,  
Ponmani M 


Loader.
Up arrow icon