Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > Grid > grid does not filter when filterBy="major~startswith~'MBA-'"
Telerik MVC Extensions are no longer supported (see this page for reference). In case you have inquiries about Kendo UI Complete for ASP.NET MVC, post them in the pertinent Kendo UI forums.

Not answered grid does not filter when filterBy="major~startswith~'MBA-'"

Feed from this thread
  • Richard avatar

    Posted on Sep 9, 2011 (permalink)

    Hi,

    I want to persist some filter expressions so that they can be reused in a dynamic way.  But I have not been able to set the filtering expression dynamically.  In my testing I thought that all I had to do was set the filterBy property of the grid to an appropriate expression and then rebind the grid.  I have not had any luck doing this.  Here is what I have tried.
    The grid is using AJAX databinding.
    I have a column named major and it has some values which begin with the characters MBA-

    In the onDataBinding function:
    var filterby = "major~startswith~'MBA-'";
     var grid = $('#TestForFilteringGrid').data('tGrid');
    grid.filterBy = filterby;

  • Joshua avatar

    Posted on Jan 5, 2012 (permalink)

    Have you found a solution to this? I'm having the exact same issue and there seems to be zero help on this subject!

  • Daniel Daniel admin's avatar

    Posted on Jan 6, 2012 (permalink)

    Hi Richard,

    To filer the data dynamically you should use the Grid's filter method.


    Greetings,
    Daniel
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now

  • Joshua avatar

    Posted on Jan 6, 2012 (permalink)

    This still does not work. What is the appropriate client side event to place this in? OnLoad?

    My code is as follows:
    The alert shows the actual filter expression (which is formatted properly), but the filter never gets applied.

     

     

     

     

     

    function onLoad(e)
        {
            var grid = $('#ExpenditureSummaryGridPSF').data("tGrid");
              
            if ("@ViewBag.FirstLoad" != "yes")
            {
            grid.filter = unescape("@ViewBag.FilterBy");
            alert(grid.filterBy);
            }
              
        }

  • Daniel Daniel admin's avatar

    Posted on Jan 6, 2012 (permalink)

    Hello,

    If you want to apply initial filtering I suggest checking the Filtering demo.
    The client-side filter method can be used at any time. For example:
    var grid = $("#Grid").data("tGrid");
    //Display all records whose OrderID property is equal to 10248
    grid.filter("OrderID~eq~10248");


    All the best,
    Daniel
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now

  • Joshua avatar

    Posted on Jan 6, 2012 (permalink)

    Thanks for the reply Daniel. What I have is two pages with virtually identical grids (save for some content) and I want the filters, sort, and groups to carry over back and forth between the pages. I have the onLoad event of the grids set and in the onLoad function am using the code above. the grid.filter just does not appear to do anything.  Any ideas or tips that might be stopping this?

    Thanks!

  • Joshua avatar

    Posted on Jan 6, 2012 (permalink)

    I have verified now that after the grid.filter() is set, I alert(grid.filterBy) and the filter is properly set, however the grid is not changing to reflect the filter

  • Joshua avatar

    Posted on Jan 6, 2012 (permalink)

    Here is the best answer (maybe the only answer) I have found yet. It simply uses the GridRouteValues to ensure the grid state is preserved.

    http://www.telerik.com/community/code-library/aspnet-mvc/grid/preserve-grid-state-between-pages.aspx

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > Grid > grid does not filter when filterBy="major~startswith~'MBA-'"
Related resources for "grid does not filter when filterBy="major~startswith~'MBA-'""

ASP.NET MVC Grid Features  |  Documentation  |  Demos  |  Telerik TV ]