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

Apply filter in chodebehind

4 Answers 51 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Naseem
Top achievements
Rank 1
Naseem asked on 28 Jun 2011, 04:39 AM
Hi,

I have a Status Column in my GridView which has got two values of "Deleted" and "Released" . When user open the page , it shows all the data included deleted and released . Then user use Status Filter to see just Deleted or Released ,or both (1.jpg).

The scenario that my client looks for is , when user open the page , it just shows the Released items and in case user wants to see deleted , it use Status filter to see deleted items as well.

For that purpose I have used the code bellow

FilterDescriptor descriptor = new FilterDescriptor();
descriptor.Member = "Status";
descriptor.Operator = FilterOperator.IsEqualTo;
descriptor.Value = "Released";
descriptor.IsCaseSensitive = true;
  
this.dgrdProduct.FilterDescriptors.Add(descriptor);

 

However by using the above code , the Deleted filter remove from filter options (2.jpg)

I need the data doesn't show deleted items in Gridview at the begining , however we have Deleted in the list of filters. It means I need to tick the Released in list of filters , when page loads in code behind(3.jpg)

I'd be thankful you guide me how I can implement that

Many Thanks,
Naseem

4 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 28 Jun 2011, 09:18 AM
Hello Naseem,

The case that you have described is a feature of the filtering control called "Cascading Distinct Values". This means that the distinct values that you see at any moment are the ones that are left after all other filters have been applied. 

You may change it and the filtering control will be working as per your requirement like this:

private void radGridView_DistinctValuesLoading(object sender, Telerik.Windows.Controls.GridView.GridViewDistinctValuesLoadingEventArgs e)
{
    e.ItemsSource = ((RadGridView)sender).GetDistinctValues(e.Column, false);
}

Please find additional information and a sample project posted by Rossen Hristov in this forum thread.

Greetings,
Didie
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Naseem
Top achievements
Rank 1
answered on 29 Jun 2011, 12:22 AM
Hi Didie,

Thank you so much for the quick response . Your solution solved part of issue. The Deleted is now included in the Filter options ,but when I tick it , it doesn't show me deleted items (infact I know the are some deleted items) . I thinks it's due to the code bellow

FilterDescriptor StatusFilter = new FilterDescriptor();
StatusFilter.Member = "Status";
StatusFilter.Operator = FilterOperator.IsEqualTo;
StatusFilter.Value = "Released";
StatusFilter.IsCaseSensitive = true;
  
this.dgrdProduct.FilterDescriptors.Add(StatusFilter);

I thought the code above is equavalent to "tick Released". I need to tick Released programically in code when data loads. (3.jpg)

Many Many thanks,
I appreciate your help,

Naseem
0
Accepted
Dimitrina
Telerik team
answered on 30 Jun 2011, 04:08 PM
Hi Naseem,

The behaviour described by you is by design. Selection is always applied over the current view only. If someone disappears from the current view, i.e. he is being filtered out, his selection is lost and there is no automatic way to bring it back. 

You will have to write some custom code that saves the current selection and then tries to restore it back. You can use RadGridView's Selection API combined with the Filtering and Filtered events ( You may reference this forum thread as well).

Best wishes,
Didie
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Naseem
Top achievements
Rank 1
answered on 01 Jul 2011, 06:12 AM
Hi Didie ,

Thank you for the answer. I'm planning to use Custom Filter Control to implement my own filtering . Hope it works.

Thank you,

Kind Regards,
Naseem
Tags
GridView
Asked by
Naseem
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Naseem
Top achievements
Rank 1
Share this question
or