Skip to main content

Hello K2 Community,

 

I found the post that explains how to clear a searched value in the quick search using jquery. 

https://community.k2.com/t5/K2-Blackpearl-Forum-Posts/SmartForm-rule-to-clear-Quick-Search-box-in-List-View/td-p/96419

 

However, I also want to clear the field that is being searched.  For example, I am search on field 'Part Number' with a value of 'ICN58160'.

 

the Jquery provided is only clearing out the 'ICN58160'.  I also want to clear out 'Part Number' so it defaults back to 'All Fields'

 

<script type="text/javascript">$(document).ready(function(){ $('input(id$="_quickSearchTxt"]').val('');});</script>

 

Can someone provide the id$= for this field?  I tried "_quickSearchFld" which didn't work.  Or, if you can provide the jquery to clear both that would be even better.

 

I searched the community and didn't see this particular question asked.  If it was I apologize, and please provide the link for that.

 

Thanks so much


16741iDED9CEBB04C54767.png

Hi Sally


 


Clearing the quick serach dropdown filter or even setting it back to its default state is not going to be as quick and easy as clearing the text field filter as there are a lot of moving parts bound to the dropdown filter due to it having it's own data source specified. The code will be quite big as all those moving parts would need to changed accordingly, not just to get the default value set by means of html changes which would require classes to be altered, add and edit, etc. but also the fact that this would need to happen when a different value is to be selected afterwards as well. 


 


The below is not a solution but could help you towards one. Looking at the moving parts from a browser inspection level I could gather that the following would need to be altered accordingly everytime a change is made to the dropdown filter. 


 


The dropdown filter will start with the value of "All fileds" being selected by default.
If it was changed by a user, the moving parts would have changed according to the selection made. Now if you were to change it back to "All fields"/default dynamically using code the html class="selected" would need to be specified in the relevant option and the html class="" would need to be specified in the remaining/previously selected class. At the same time the spanned title and text would need to be changed accordingly to match the selected value (this is displayed in screenshot 1). 



With the above being mentioned since there are quite a lot of moving part that would need altering on the fly and with the fact the K2 Support does not support custom code or custom changes I would instead suggest creating your own filters using the out of the box controls.


 


 


Regards


 


 


Reply