Column sorting and retaining filter

2 posts, 0 answers
  1. hchattaway
    hchattaway avatar
    67 posts
    Member since:
    Feb 2007

    Posted 29 Aug 2008 Link to this post

    I am using the RadGrid with a LinqDatasource, which is working great. I made the columns sortable and I have a couple of fields above the grid I use to filter the grid. The filtering works great also, but when I click on a column header, the filtering is not kept. Do I need to recreate the filter on each click of a column header?

    I am creating the filter in the codebehind like this:
    Parameter Projectparam = new Parameter(); 
    Projectparam.Name = "ProjectID"
    Projectparam.DefaultValue = this.UserInfo.Profile.GetPropertyValue("ProjectID").ToString(); 
    Projectparam.Type = TypeCode.Int32; 
    TicketListDataSource.WhereParameters.Add(Projectparam); 
     
    TicketListDataSource.Where = "ProjectID == @ProjectID" 

    Should this filtering logic be run each time a column header is clicked? Using the "OnSortCommand"?
    Thanks!
    Harold

  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 01 Sep 2008 Link to this post

    Hi Harold,

    Generally if you bind the grid using DataSourceID all these will be done automatically. Please check this example:
    http://demos.telerik.com/aspnet/Prometheus/Grid/Examples/GeneralFeatures/ASPNET35/DefaultCS.aspx

    Sincerely yours,
    Vlad
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top