This is a migrated thread and some comments may be shown as answers.

How can I prevent a filter row from hitting the server unless the user clicks a button or presses enter?

4 Answers 354 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Developer
Top achievements
Rank 1
Developer asked on 03 Feb 2016, 10:46 PM
I have a filter row on a grid and it seems that every time the filter inputs are used (loss of focus from tabbing out, or clicked on if radio button, or selected if dropdown) the grid hits the server. I'd like the users to have to explicitly hit enter or press a button of my choice to actually perform the data source filter request. Any ideas?

4 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 08 Feb 2016, 12:19 PM

Hello Developer,

 

I am afraid that this can not be achieved with the built-in filter row mode. It uses MVVM internally in order to handle the user interaction and filter the DataSource.

 

My suggestion is to use a complete separate filter form outside the Kendo UI Grid and use the API of the Kendo UI DataSource in order to filter the grid when user clicks on the filter button or press enter. For example filter method  will filter the data in the Kendo UI DataSource and the grid will refresh. 

 

Regards,
Boyan Dimitrov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Developer
Top achievements
Rank 1
answered on 08 Feb 2016, 02:31 PM

The problem with that is that it renders the filter configuration, which is quicker/easier useless and now it's a custom form outside of the framework.

Is there really no way that a function/property/event can be manipulated to make this work? This is JavaScript after all, I just haven't dug into the source enough.

0
Boyan Dimitrov
Telerik team
answered on 10 Feb 2016, 01:40 PM

Hello Developer,

 

Indeed it will be easier to use the built-in filter menu/elements, but there is no easy way to prevent the filtering when the filter input looses its focus. Actually the main idea (by design) is to trigger the filter when user moves the focus out of the element. 

 

 

Regards,
Boyan Dimitrov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
1
Developer
Top achievements
Rank 1
answered on 10 Feb 2016, 03:03 PM

I "hacked" a way together that preserves the grid functionality I need (mainly filtering/sorting/selecting). What I've done is capture specific events that I deem as allowable to go to the server. I then set a boolean field to true. Then in the dataSource requestStart event I check the boolean field and if it's false I do event.preventDefault() so that the request won't continue. I've also got a requestEnd event that sets the boolean to false every time the request finishes. This allows me to filter only on what I consider a submission as well as sort on click (the sorting had to be done because my requestStart was preventing it from working).

Tags
Grid
Asked by
Developer
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Developer
Top achievements
Rank 1
Share this question
or