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

[Solved] Hiding a row in GridView

3 Answers 155 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.
Silverlight Student
Top achievements
Rank 1
Silverlight Student asked on 17 Sep 2009, 02:11 PM
Hi,

How I can hide a row in the GridView in my SL3 application ?
Visibility mode is based on a binding value as shown below
Visibility="{Binding Path=IsChecked, Converter={StaticResource boolToVis}}

Thanks in advance,







3 Answers, 1 is accepted

Sort by
0
Kalin Milanov
Telerik team
answered on 22 Sep 2009, 09:08 AM
Hello Silverlight Student,

I am sending you a sample application which hides and shows the third row. Hopefully it will point you in the direction to resolve the issue you are having. If this is not the case (as you are using Converter and IsChecked binding) can you please send me a sample so I can provide you with further assistance.

Kind regards,
Kalin Milanov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Silverlight Student
Top achievements
Rank 1
answered on 22 Sep 2009, 12:02 PM
Hi,

Thanks for the reply. But I need it in XAML.
Because I am binding with data in XAML.

Here is the way I am defining telerik data grid control.
In it, I have a textblock (first column) and a text box (in 2nd column) in each row (ie, 2 columns in a row).

I am binding this to the Employee details.
So the text block will dispaly employee name and the text box will display salary.

While setting the data context of the grid to employee collection, it will populate more employee details in the grid.
(each row displays employee name and salary).

Based on a value in my Employee details, how can I hide a row in the grid in the XAML ?
Suppose in the EmployeeDetails, i have a boolean property like IsVisible. Based on the value of IsVisible, each row is showing.

How can I set it in XAML ?


<

 

telerikGrid:RadGridView Name="myGrid"

 

 

Height="110"

 

 

Margin="5,5,5,5"

 

 

ItemsSource="{Binding Path=EmployeeDetails}"

 

 

AutoGenerateColumns="False"

 

 

RowIndicatorVisibility="Collapsed"

 

 

IsFilteringAllowed="False"

 

 

UseAlternateRowStyle="True">

 

 

 

<telerikGrid:RadGridView.Columns>

 

 

 

<telerikGrid:GridViewDataColumn IsReadOnly="True"

 

 

Width="375"

 

 

HeaderTextAlignment="Center"

 

 

HeaderText="Employee"

 

 

UniqueName="Employee"

 

 

IsVisible="True">

 

 

 

<telerikGrid:GridViewDataColumn.CellStyle>

 

 

 

<Style TargetType="telerikGridView:GridViewCell">

 

 

 

<Setter Property="Template">

 

 

 

<Setter.Value>

 

 

 

<ControlTemplate TargetType="telerikGridView:GridViewCell">

 

 

 

<TextBlock Margin="3,0,2,0"

 

 

Width="Auto"

 

 

HorizontalAlignment="Stretch"

 

 

Text="{Binding Path=EmployeeName, Mode=TwoWay}" />

 

 

 

</ControlTemplate>

 

 

 

</Setter.Value>

 

 

 

</Setter>

 

 

 

</Style>

 

 

 

</telerikGrid:GridViewDataColumn.CellStyle>

 

 

 

</telerikGrid:GridViewDataColumn>

 

 

 

 

<telerikGrid:GridViewDataColumn IsReadOnly="True"

 

 

IsResizable="False"

 

 

Width="130"

 

 

HeaderTextAlignment="Center"

 

 

TextAlignment="Salary"

 

 

HeaderText="Salary"

 

 

UniqueName="Salary"

 

 

IsVisible="True">

 

 

 

<telerikGrid:GridViewDataColumn.CellStyle>

 

 

 

<Style TargetType="telerikGridView:GridViewCell">

 

 

 

<Setter Property="Template">

 

 

 

<Setter.Value>

 

 

 

<ControlTemplate TargetType="telerikGridView:GridViewCell">

 

 

 

<TextBox Name="txtCredit" TextAlignment="Right"

 

 

Text="{Binding Path=Salary, Mode=TwoWay}"

 

 

locals:UpdateSourceTriggerBinding.UpdateSourceOnChange="True"

 

 

Width="Auto" Height="20" />

 

 

 

</ControlTemplate>

 

 

 

</Setter.Value>

 

 

 

</Setter>

 

 

 

</Style>

 

 

 

</telerikGrid:GridViewDataColumn.CellStyle>

 

 

 

</telerikGrid:GridViewDataColumn>

 

0
Kalin Milanov
Telerik team
answered on 25 Sep 2009, 08:54 AM
Hello Silverlight Student,

The behavior you are explaining sounds a lot like filtering. The RadGridView supports definition of FilterDescriptors which will filter your data following a predefined condition. Attached I enhanced the sample previously provided to display all rows in which the Property5 column cells have value less than 10005.

It is defined entirely in XAML and there and it does not need to have a more complex logic a binding and using converters.

Greetings,
Kalin Milanov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Silverlight Student
Top achievements
Rank 1
Answers by
Kalin Milanov
Telerik team
Silverlight Student
Top achievements
Rank 1
Share this question
or