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

How do I hide a row?

5 Answers 593 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kennet
Top achievements
Rank 2
Kennet asked on 15 Jul 2010, 05:46 PM
I try to hide a row that have a specific status, When I do like the code below. the row is not shown, but there is space left "blank" in the grid where the row should be. I also tested with Height=0

private void radGrid_RowLoaded(object sender, RowLoadedEventArgs e)
{
    GridViewRow row = e.Row as GridViewRow;
    if (row != null)
    {
                 
        MyClass _MyClass = row.DataContext as MyClass;
        if (row != null && _MyClass != null)
        {
            row.IsExpandable = _MyClass.Category.Equals(5);
        }
        else
        {
            row.IsExpandable = false;
        }
 
        if (_MyClass.MediaCategory.Equals(5) && _MyClass.Status.Equals(-1))
        {
           row.Visibility = System.Windows.Visibility.Collapsed;
        }
     }
}

Any suggestions?

/Ken

5 Answers, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 16 Jul 2010, 10:20 AM
Hello Kennet,

 In this scenario it is best to use filtering. Here's how you can do what you want in XAML:

<telerik:RadGridView ...>
    <telerik:RadGridView.FilterDescriptors>
        <telerik:CompositeFilterDescriptor LogicalOperator="Or">
            <telerik:CompositeFilterDescriptor.FilterDescriptors>
                <telerik:FilterDescriptor Member="Status" Operator="IsNotEqualTo" Value="5"/>
                <telerik:FilterDescriptor Member="Status" Operator="IsNotEqualTo" Value="-1"/>
            </telerik:CompositeFilterDescriptor.FilterDescriptors>
        </telerik:CompositeFilterDescriptor>
    </telerik:RadGridView.FilterDescriptors>
</telerik:RadGridView>

Kind regards,
Yavor Georgiev
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
Kennet
Top achievements
Rank 2
answered on 16 Jul 2010, 01:01 PM
That is not working for me, and I need to have "IsFilteringAllowed=False" on the RadGrid.

Is there any other way to do it? I prefere with C# code.

/Ken
0
Yavor Georgiev
Telerik team
answered on 16 Jul 2010, 01:10 PM
Hello Kennet,

 Unfortunately, you cannot modify the visibility of a GridViewRow, because that would seriously tamper with virtualziation.

The IsFilteringAllowed property controls whether users can filter the grid via the filtering icon in GridViewHeaderCell. The approach I have suggested still works with this property set to false.

Could you please send me your application so I can see why the filtering does not work?

Greetings,
Yavor Georgiev
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
Kennet
Top achievements
Rank 2
answered on 16 Jul 2010, 01:20 PM
Hi Yavor,

Good to hear that filter works without flags visible in header.

I can't send you my project since it a part of a big project, I will try to take the time to make a mackup on just this function.

How Can I do the filtering by code?

/Ken
0
Accepted
Pavel Pavlov
Telerik team
answered on 16 Jul 2010, 01:41 PM
Hello Kennet,

You can learn more about programatic filtering here.

Sincerely yours,
Pavel Pavlov
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
Tags
GridView
Asked by
Kennet
Top achievements
Rank 2
Answers by
Yavor Georgiev
Telerik team
Kennet
Top achievements
Rank 2
Pavel Pavlov
Telerik team
Share this question
or