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

[Solved] How to hide Row by condition

5 Answers 366 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Konstantin
Top achievements
Rank 1
Konstantin asked on 22 Feb 2011, 01:22 PM
I need to hide row in Grid depends on condition.
I tried following approaches:
1. Handle RowLoaded event and change e.Row.Visibility
Row is disappear, but empty space is still visible
2. Copy and modify template for GridViewRow. I created converter for Visibility property.
    2.1. If I use this converter for Visibility property to Root Border or to SelectiveScrollingGrid. Row is Row is disappear, but empty space is still visible
    2.2 If I use this converter for DataCellsPresenter. Only selection border is visible and row has very small height, but doesn't disappear

Is it possible to solve me issue?

5 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 22 Feb 2011, 02:13 PM
Hi Konstantin,

 
This is the expected behavior. Any attempt to play with the Visibility property of a GridViewRow will result in such a behavior. To get the one you need, you may filter the items rather than set their visibility. Pplease refer to the following article.


Best wishes,
Vanya Pavlova
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Konstantin
Top achievements
Rank 1
answered on 22 Feb 2011, 02:25 PM
Two issues:
  1. My filtering condition is related to private property (as a part of explicit interface implementation) of Data item
  2. This property need to be invisible to user. As a result I can't afford to show it in GridView header
0
Vanya Pavlova
Telerik team
answered on 22 Feb 2011, 03:03 PM
Hi Konstantin,

 
May you share with us the source code you are currently using? If you need to filter these values, you have to mark this property as public. In case this property should not be visible to the end-users, just set the IsVisible property of its corresponding GridViewDataColumn to False:

<telerik:RadGridView x:Name="gridView1" AutoGenerateColumns="False">
           <telerik:RadGridView.FilterDescriptors>
               <telerik:FilterDescriptor Member="Age"  Operator="IsEqualTo"
                            Value="32"
                            IsCaseSensitive="False"/>
           </telerik:RadGridView.FilterDescriptors>
           <telerik:RadGridView.Columns>
               <telerik:GridViewDataColumn Header="FirstName" DataMemberBinding="{Binding FirstName}"/>
               <telerik:GridViewDataColumn Header="LastName" DataMemberBinding="{Binding LastName}"/>
               <telerik:GridViewDataColumn Header="Married" DataMemberBinding="{Binding Married}"/>
               <telerik:GridViewDataColumn  Header="Age" DataMemberBinding="{Binding Age}" IsVisible="False"/>
           </telerik:RadGridView.Columns>
       </telerik:RadGridView>


I will be waiting for your response.

Regards,
Vanya Pavlova
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Konstantin
Top achievements
Rank 1
answered on 22 Feb 2011, 03:09 PM
It's code from my Converter:
var editableObject = value as IEditableObjectInfo;
if (editableObject != null)
{
    return editableObject.IsAdding ? Visibility.Collapsed : Visibility.Visible;
}
return Visibility.Visible;

Data Item is implementing IEditableObjectInfo explicitly. I can't change it.
0
Ivan Ivanov
Telerik team
answered on 25 Feb 2011, 03:29 PM
Hi Konstantin,

Unfortunately, Silverlight doesn't support obtaining private property values via reflection. Moreover changing GridViewRow's template may lead to critical  visual issues in other scenarios of your application. The only solution that comes to my mind is modifying your ViewModel by adding a public property that could act as a mark to the filtering and doesn't interfere with your interface definition. Of course, it doesn't need to be shown in a column of your RadGridView.
Please, do not hesitate to contact us, if you have any further questions.

Best wishes,
Ivan Ivanov
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
GridView
Asked by
Konstantin
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Konstantin
Top achievements
Rank 1
Ivan Ivanov
Telerik team
Share this question
or