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

Questions about refresh and filters with a custom search plugin

5 Answers 159 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jacob
Top achievements
Rank 2
Jacob asked on 19 May 2015, 08:57 PM

Hi,

My team is writing a custom search plugin for our Kendo grids. We are able to get the query and related functionality to work correctly, but we have had to do a couple of hacky things to get there.  I was wondering if there were more formal and better ways to handle a couple of the problems we are facing. I will first list them as plain questions before describing any details:

 1. How can I add a filter to dataSource.filter without having that affect the filter indicator on the UI? 

 2. What is the best way to override the functionality of the 'refresh' button?

For us, those to questions are very related. Basically, we would love to have our custom search work by just adding an additional filter to dataSource.filter. However, we cannot do that because it will trigger the filter indicator on the UI (and we don't want that). So we've written a backdoor way of passing in our extra search filter to avoid the UI change.  However, when we do that the 'refresh' button does not know about our extra filter. Instead the 'refresh' button calls directly into dataSource.read(), which bypasses the functionality we added and would only respect filters if we persist the search filter to the grid's set of filters (back to the UI indication trigger problem).

Any help would be appreciated.  Thank you!

5 Answers, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 21 May 2015, 03:02 PM
Hello Jacob,

Applying any changes to the filtering criteria through the DataSource's filter method will result in UI change. You can try passing the extra filters through the transport.read.data option - this will guarantee that it will be sent event when the read method is called.

Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Jacob
Top achievements
Rank 2
answered on 28 May 2015, 07:44 PM

Unfortunately the transport.read.data option is not sufficient. We cannot use that to hook into the normal filters object -- as the documentation states, "The parameter names must not match reserved words, which are used by the Kendo UI DataSource for sorting, *filtering*, paging and grouping".  Also this option is only part of the API for server-bound grids, so it would not be sufficient for all grids (including non-server-bound grids). 

Do you have any insights on either of these other options?

(A): What is the best way to override the functionality of the 'refresh' button?

or 

(B): Is there a way to hook into the filter menu (through such events like filterMenuOpen and filterMenuClose, which could exist as the filterMenuInit event does)?  Those events could enable you to modify filters before and after closing the filter menu, and then we could directly modify the filters object on the datasource and not worry about the UI impact.

0
Alexander Popov
Telerik team
answered on 01 Jun 2015, 11:57 AM
Hi Jacob,

You can use a custom toolbar command instead of the built-in refresh button and call a JavaScript function that follows your requirements. If you prefer using the standard refresh button you can remove its "k-pager-refresh" class on which the default click event handler is attached, then attach your own.
There are no open and close events for the filter menu. You can subscribe to the open and close events of the popup in which the menu is rendered (see example), although I am not sure how this will help.

Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Jacob
Top achievements
Rank 2
answered on 03 Jun 2015, 04:25 PM

Alexander, thank you for the response.  Those ideas were helpful.

We may keep our current hack in place or go with the hacks to fix refresh. Unfortunately the close event fires after the filters are applied, so it is too late to use. 

Looking forward, we would like to suggest that the Kendo Grid API be extended to include the ability to hook into refresh or filters (without updating the UI).  Should we do this in the feedback portal? http://kendoui-feedback.telerik.com/forums/127393-telerik-kendo-ui-feedback

Thank you,

Jacob

0
Alexander Popov
Telerik team
answered on 05 Jun 2015, 08:05 AM
Hi Jacob,

Yes, the feedback portal is the right place to submit this suggestion. This will allow users to vote for the idea, which in turn will help us prioritize it.

Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Jacob
Top achievements
Rank 2
Answers by
Alexander Popov
Telerik team
Jacob
Top achievements
Rank 2
Share this question
or