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

Iterate through the kendo grid filters

9 Answers 564 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ajay
Top achievements
Rank 1
Ajay asked on 25 Sep 2014, 11:57 PM
I have a weird situation where I have 5 filterable columns on my grid and have a filter button outside my grid. I need to specify the filters and have the grid not filter right away. The user then clicks the Filter button and then i need to pass my filters to the controller. How do I do that and how do i iterate through the filter collection and set filter values to a concrete filter object :
public class GridFilters
{
    public string FieldName {get;set;}.... 

9 Answers, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 29 Sep 2014, 04:19 PM
Hello Ajay,

What I would suggest you to do is use the requestStart event of the dataSource in order to prevent the request, when you want to disable the filtering and then allow the request when you want to filter. This will work, because the filtering performs a request to the remote dataSource, and you can just prevent this request if you do not want to filter. Here is an example that I created for you, I hope it will help:

http://dojo.telerik.com/UgIk

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Ajay
Top achievements
Rank 1
answered on 29 Sep 2014, 11:43 PM
Hello Kiril,

thank you for your solution.

I tried your solution and it works when I have set a bool variable in the javascript. But the problem I am facing now is the sort will not trigger on the column since the bool value is preventing it to send request to the server for sorting. I have to do both serverside filtering and sorting.

Any help would be appreciated.

0
Kiril Nikolov
Telerik team
answered on 30 Sep 2014, 08:07 AM
Hi Ajay,

Well this behavior is expected as in the requestStart you basically prevent the request and it never reaches the server. I am afraid that this cannot be worked around, as you can either allow or block the request to the server for the filter/sort operations.

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Ajay
Top achievements
Rank 1
answered on 01 Oct 2014, 11:52 PM
Hi Kiril,

Thanks for the response. I will try to figure a work around for this. I have another question though.
In my grid I have specified my grid filterable mode = “row” (similar to your example here http://demos.telerik.com/kendo-ui/grid/filter-row). Can I implement filter menu customization as seen in ("http://demos.telerik.com/kendo-ui/grid/filter-menu-customization")
? What I am trying to do is for a column, for example US States, I want to show a dropdown list of States when the filterable mode is “row” , instead of a textbox where a user types in the state. If so, could you please point me to an example.

Thanks
0
Kiril Nikolov
Telerik team
answered on 02 Oct 2014, 11:37 AM
Hi Ajay,

You can use template for the filter row column like this:

http://dojo.telerik.com/UqeSE

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Ajay
Top achievements
Rank 1
answered on 02 Oct 2014, 02:26 PM
Thanks Kiril,
I tried this but I am getting an error (Unable to get the property 'dataSource' of undefined or null reference). I believe this is because how I define the grid options. We are using angular JS with Kendo. I have attached my js file which has the grid options. the column is question is "HasAgreement". I have attached my js file and your help is appreciated.
Thanks
0
Kiril Nikolov
Telerik team
answered on 03 Oct 2014, 11:11 AM
Hello Ajay,

As I have not seen which is the controller and the $scope statements in your code. This is why I have tested the same functionality with a Kendo UI Grid with AngularJS, please check it out and see the working example:

http://dojo.telerik.com/iKoJ

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Ajay
Top achievements
Rank 1
answered on 07 Oct 2014, 03:46 PM
Hi Kiril, 
Thanks for the example, but I can't seem to get it to work maybe because how i declare my directives. My controller call the service which has the gridoptions and for some reason it cannot finf the kendo directive for the filters. I have attached my directive/controller/service js file for your reference.
thanks
Ajay
0
Kiril Nikolov
Telerik team
answered on 08 Oct 2014, 12:20 PM
Hi Ajay,

I was not able to see anywhere in your code where you include the Kendo UI Directives, as well as the ng-app definition. Would it be possible to extract a fully runnable sample where the issue is reproduced, so we can take a deeper look?

Regards,
Kiril Nikolov
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
Ajay
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Ajay
Top achievements
Rank 1
Share this question
or