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

Retaining Gridview filtering

7 Answers 81 Views
GridView
This is a migrated thread and some comments may be shown as answers.
sony
Top achievements
Rank 1
sony asked on 12 Oct 2011, 06:46 AM
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??

7 Answers, 1 is accepted

Sort by
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 12 Oct 2011, 07:56 AM
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
0
sony
Top achievements
Rank 1
answered on 12 Oct 2011, 08:04 AM
Hi,

Thanks for the reply,
I will let you know if i face any problem.
0
Emanuel Varga
Top achievements
Rank 1
answered on 12 Oct 2011, 08:44 AM
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
0
sony
Top achievements
Rank 1
answered on 12 Oct 2011, 08:59 AM
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
0
Stefan
Telerik team
answered on 14 Oct 2011, 12:15 PM
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.

0
sony
Top achievements
Rank 1
answered on 14 Oct 2011, 12:22 PM
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.
0
Stefan
Telerik team
answered on 18 Oct 2011, 03:02 PM
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.

Tags
GridView
Asked by
sony
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
sony
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or