Search when typing

How can change the search settings of the grid to search by keypress?  

Now when the Enter key is pressed, search in the grid is started. I want to search when the user types any character without press the Enter key.

1 Reply 1 reply marked as answer

VS Vignesh Sivagnanam Syncfusion Team March 15, 2021 12:17 PM UTC

Hi Fereydoon, 

Thanks for contacting Syncfusion support. 

Query: How can change the search settings of the grid to search by keypress?  Now when the Enter key is pressed, search in the grid is started. I want to search when the user types any character without press the Enter key. 
 
Based on your query you want to perform searching in the Grid component while typing in the search box without pressing the enter key. So, we have prepared sample and in that we have used the created event of the Grid component to achieve your requirement. 

In the created event we have set the keydown event for the search box and performed the searching by calling the search method of the Grid component. For your convenience we have attached the sample, please refer them for your reference. 

Code Example: 
App.vue 

  methods: { 
    onCreate: function () { 
      var gridObj = this.$refs.grid; 
      gridObj.$el.addEventListener("keydown", function (event) { 
        if (event.target.parentElement.classList.contains("e-search")) { 
          setTimeout(function () { 
            gridObj.search(event.target.value); 
          }); 
        } 
      }); 
    }, 
  }, 


Please get back to us if you need further assistance. 

Regards, 
Vignesh Sivagnanam. 


Marked as answer
Loader.
Up arrow icon