0

I want to implement search functionality depending on the column.

Suppose I have a column name "Country" then on the basis of the country column different countries are available in drop-down and click on one country will filter the SharePoint list.

But the major issue is that I have 100 columns and when user type any column name in input field, it will populate all the drop-down corresponding to that column in the drop-down field and depending on that filter will be applied on the list.

  • How is that different from the out of the box column filter functionality? – Matthew McDermott Feb 17 '18 at 13:49
  • Actually as per my knowledge filter works for only one column but I have 100 of columns(choice) . So, what I exactly need a search box where column name(on the basis of display name) to be entered and a dropdown where choice option will be there. So when user type any column name in search box and then select any choice option from dropdown list need to be filtered based on column name and value of choice it contains. – Ashutosh Agarwal Feb 20 '18 at 6:30
  • Have you looked at the advanced search web part? – Matthew McDermott Feb 20 '18 at 12:50
  • Advance search webpart gives search results in different format. Is there a way to have search result shown in list format? – Ashutosh Agarwal Feb 26 '18 at 5:40
  • Yes, you create a Control and Item Display template that produces the UI that you want in the Search Center. – Matthew McDermott Feb 26 '18 at 16:22
2

I think a cool way to handle this would be to use dataTables JS-library which queries your list's REST API and provides the relevant filter/search fields. Because someone else has thought about this earlier as well, there's this many times referenced article Who Needs a Data View Web Part? SharePoint REST and DataTables (YouTube-version: https://www.youtube.com/watch?v=f4S3qo3kWz8) describing what should be done, step-by-step. You might also want to have a look at questions tagged as as most of them attempt to achieve a similar requirement.

To get started, add the required JS files (jQuery, dataTables) to your SharePoint's shared library (Site Assets would be the best). Then create your HTML for the search fields and for the search-button. Finally implement the JS function which would be fired with the search-button. The JS function shall do a REST call to your SP list's REST API in ajax and wrap the results into a JSON format. Finally the function shall lay the retrieved data into the dataTables according to its own syntax.

| improve this answer | |
  • Sorry I think I am not able to present my question actual problem is:-Actually as per my knowledge filter works for only one column but I have 100 of columns(choice) . So, what I exactly need a search box where column name(on the basis of display name) to be entered and a dropdown where choice option will be there. So when user type any column name in search box and then select any choice option from dropdown. list need to be filtered based on column name and value of choice it contains. – Ashutosh Agarwal Feb 20 '18 at 6:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.