Client-side Filtering

4 posts, 0 answers
  1. Kaan
    Kaan avatar
    7 posts
    Member since:
    Jul 2016

    Posted 24 Nov 2016 Link to this post

    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.

  2. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1502 posts

    Posted 28 Nov 2016 Link to this post

    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.
  3. Kaan
    Kaan avatar
    7 posts
    Member since:
    Jul 2016

    Posted 28 Nov 2016 in reply to Danail Vasilev Link to this post

    Hi Danail,

    For the second question, what is your opinion?

  4. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1502 posts

    Posted 29 Nov 2016 Link to this post

    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.
Back to Top