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
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.
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>
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.