Retaining Gridview filtering

8 posts, 1 answers
  1. sony
    sony avatar
    2 posts
    Member since:
    Aug 2010

    Posted 12 Oct 2011 Link to this post

    Hi all,


    Retaining Gridview filtering:
    I have radgrid in my form.
    My requirement is i am giving filter conditions to some columns.
    Now I want to edit a row,so after I go to the edit page and return to the grid I want to see my grid in the same page.
     grid will be lost upon Rebind(). After Update also i want to maintain same filtering conditions.

    How can i achieve this??
  2. Answer
    Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 12 Oct 2011 Link to this post

    Hello,

    Just store the filter descriptors and readd them afterwards, 
    var activeDescriptors = _radGridView.FilterDescriptors.ToArray();
     
    // do stuff here, rebind, and so on.
     
    _radGridView.FilterDescriptors.AddRange(activeDescriptors);

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga

    Telerik WinForms MVP
  3. UI for WinForms is Visual Studio 2017 Ready
  4. sony
    sony avatar
    2 posts
    Member since:
    Aug 2010

    Posted 12 Oct 2011 Link to this post

    Hi,

    Thanks for the reply,
    I will let you know if i face any problem.
  5. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 12 Oct 2011 Link to this post

    Glad to be able to help,

    If you have any more questions please just let me know, and if the question has been solved, please mark the question as answered, so that others can find the answers to their questions faster.

    Best Regards,
    Emanuel Varga

    WinForms MVP
  6. sony
    sony avatar
    2 posts
    Member since:
    Aug 2010

    Posted 12 Oct 2011 Link to this post

    Hi Emanuel varga,


    At  Second line, 
    _radGridView.FilterDescriptors.AddRange(activeDescriptors);

    Iam getting the exception

    "Unable to cast object of type 'Telerik.WinControls.Data.FilterDescriptor[]' to type 'Telerik.WinControls.Data.FilterDescriptor'."


    Plz help me
  7. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 14 Oct 2011 Link to this post

    Hello guys,

    Thank you both for writing.

    @sony, I have tested Emanuel's code and it works correctly on my end. Could you please share with us, which version of RadControls for WinForms you are using?

    Thank you in advance for your time and cooperation.
     
    Regards,
    Stefan
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

  8. sony
    sony avatar
    2 posts
    Member since:
    Aug 2010

    Posted 14 Oct 2011 Link to this post

    Hi,

    dnt know stefan why that error, at last i solved my problem by doing the below after binding 

     
      grid.MasterGridViewTemplate.FilterDescriptors.Clear()
                For Each fe As FilterDescriptor In activedescriptors
                    grid.Columns(fe.PropertyName).FilterDescriptor = fe
                Next


    It is working fine......
    Thanks for the replies.
  9. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 18 Oct 2011 Link to this post

    Hi Sony,

    I am glad to hear that you have solved your issue. Should you have any other questions, do not hesitate to open a new thread.
     
    All the best,
    Stefan
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

Back to Top
UI for WinForms is Visual Studio 2017 Ready