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

Client-side Filtering

3 Answers 2054 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kaan
Top achievements
Rank 1
Kaan asked on 24 Nov 2016, 01:43 PM

Hi,

I've almost over 200+ grids in my app. I am trying to add a external search area to search in all columns

 

$('.k-grid').each(function () {
            var $gridElement = $(this);
            var $grid = $gridElement.data('kendoGrid');

            var toolbar = $grid.table.prev('.k-grid-toolbar');
            if (toolbar.length > 0)
            {
                var searchContainer = $('<div style="width: 200px; float:right;"></div>').appendTo(toolbar);
                var searchBox = $('<input type="text" class="form-control"/>')
                    .appendTo(searchContainer)
                    .on('keyup', function () {
                        var val = $(this).val();

                        var filters = [];
                        $.each($grid.columns, function (i, item) {
                            if(item.field && item.field.length > 0)
                            {
                                filters.push({ field: item.field, operator: 'contains', value: val })
                            }
                        });
                        $grid.dataSource.filter({
                            logic: "or",
                            filters: filters
                        });
                    });
            }

....................

 

But I've two problems:

    1) It does filtering in server-side, I want to make it in client-side.

    2) Because I'm binding some columns with SelectLists, I cannot search amoung them. 

 

Do you have any suggestions?

Regards.

3 Answers, 1 is accepted

Sort by
0
Danail Vasilev
Telerik team
answered on 28 Nov 2016, 07:31 AM
Hello Kaan,

To have a client-side filtering you should disable all the server operations. More information on the matter is available here - http://docs.telerik.com/aspnet-mvc/helpers/grid/faq#how-to-configure-grids-to-perform-paging-sorting-filtering-and-grouping-in-memory In that case, however, you will get all the data on the client-side.

Regards,
Danail Vasilev
Telerik by Progress
Telerik UI for ASP.NET MVC is ready for Visual Studio 2017 RC! Learn more.
0
Kaan
Top achievements
Rank 1
answered on 28 Nov 2016, 09:22 AM

Hi Danail,

For the second question, what is your opinion?

0
Danail Vasilev
Telerik team
answered on 29 Nov 2016, 03:02 PM
Hi Kaan,

If you are using a foreign column you should filter by the value and not the text. You can, for example find the value by text before that.

Regards,
Danail Vasilev
Telerik by Progress
Telerik UI for ASP.NET MVC is ready for Visual Studio 2017 RC! Learn more.
Tags
Grid
Asked by
Kaan
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
Kaan
Top achievements
Rank 1
Share this question
or