Hi,
when move out of checkbox column, i loose the UI/display status on checkbox.
It is always displays unchecked box.
Though it is retaining the values.
I am not rebinding the source after check/uncheck of checkbox.
what could be the reason?
thanks
virendra
9 Answers, 1 is accepted
0
Hi Virendra,
I didn't manage to reproduce such issue in our online examples - can you send us a bit more info how to reproduce this?
Best wishes,
Vlad
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
I didn't manage to reproduce such issue in our online examples - can you send us a bit more info how to reproduce this?
Best wishes,
Vlad
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Hector
Top achievements
Rank 1
answered on 05 Jun 2009, 01:10 PM
I had the same problem. I added a column with a checkbox through the control template. During runtime, they display fine for every row, but when I check them on and I scroll up or down past the checked items, then scroll back to those items, they are unchecked.
I am trying to add a check box to each row to select or unselect the rows. How can I accomplish this?
Thanks, Hector
Here is part of my code:
I am trying to add a check box to each row to select or unselect the rows. How can I accomplish this?
Thanks, Hector
Here is part of my code:
Page.xaml
<ControlTemplate x:Key="AccountTypesTemplate" TargetType="telerikGV:GridViewRow" > | ||||||||||||||||
<Border x:Name="rowsContainer" Background="#FF525252" Padding="8,8,8,0" > | ||||||||||||||||
<Border Background="{StaticResource Office_BlackRowBackground}" x:Name="selectedRow" | ||||||||||||||||
BorderThickness="1" BorderBrush="#FF000000" > | ||||||||||||||||
<Grid Width="400"> | ||||||||||||||||
<Grid.RowDefinitions> | ||||||||||||||||
<RowDefinition Height="30" /> | ||||||||||||||||
<RowDefinition Height="30" /> | ||||||||||||||||
</Grid.RowDefinitions> | ||||||||||||||||
<Grid.ColumnDefinitions> | ||||||||||||||||
<ColumnDefinition Width="30" /> | ||||||||||||||||
<ColumnDefinition Width="55" /> | ||||||||||||||||
<ColumnDefinition Width="*" /> | ||||||||||||||||
<ColumnDefinition Width="60" /> | ||||||||||||||||
<ColumnDefinition Width="*" /> | ||||||||||||||||
</Grid.ColumnDefinitions> | ||||||||||||||||
<CheckBox Grid.Column="0" Grid.Row="0" IsChecked="False" Grid.RowSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" | ||||||||||||||||
Margin="5,5,5,5"/> | ||||||||||||||||
<TextBlock Grid.Column="1" Grid.Row="1" Foreground="White" FontWeight="Bold" Margin="0,15,15,0" | ||||||||||||||||
VerticalAlignment="Top" HorizontalAlignment="Left" Text="Phone:" /> | ||||||||||||||||
<TextBlock Grid.Column="3" Grid.Row="1" Foreground="White" FontWeight="Bold" Margin="0,15,15,0" | ||||||||||||||||
VerticalAlignment="Top" HorizontalAlignment="Left" Text="Group:" /> | ||||||||||||||||
<!--Cells--> | ||||||||||||||||
<telerikGV:GridViewCell Grid.Column="1" Grid.Row="0" Foreground="White" FontWeight="Bold" Margin="0,15,15,0" | ||||||||||||||||
VerticalAlignment="Top" HorizontalAlignment="Left" Value="{Binding Description}" Grid.ColumnSpan="4" /> | ||||||||||||||||
<telerikGV:GridViewCell Grid.Column="2" Grid.Row="1" Foreground="White" FontWeight="Bold" Margin="0,15,15,0" | ||||||||||||||||
VerticalAlignment="Top" HorizontalAlignment="Left" Value="{Binding Value}" /> | ||||||||||||||||
<telerikGV:GridViewCell Grid.Column="4" Grid.Row="1" Foreground="White" FontWeight="Bold" Margin="0,15,15,0" | ||||||||||||||||
VerticalAlignment="Top" HorizontalAlignment="Left" Value="{Binding GroupName}" /> | ||||||||||||||||
</Grid> | ||||||||||||||||
</Border> | ||||||||||||||||
</Border> | ||||||||||||||||
</ControlTemplate>
|
0
Hello Hector,
You will need to bind (TwoWay) this CheckBox to IsSelected DataRecord property. Grid rows are UI virtualized and every row outside of the viewble area will be destroyed and created again when needed.
Best wishes,
Vlad
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
You will need to bind (TwoWay) this CheckBox to IsSelected DataRecord property. Grid rows are UI virtualized and every row outside of the viewble area will be destroyed and created again when needed.
Best wishes,
Vlad
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Hector
Top achievements
Rank 1
answered on 05 Jun 2009, 01:55 PM
OK, this makes sence, Vlad. Can you show me an example of how to bind the checkbox to the DataRecord property? I am thinking that I don't have my GridView columns set correct for the Checkbox. I only have the checkbox in the ControlTemplate, but not in the <telerikGridView:RadGridView.Columns> I am thinking that this is where I need to bind it, right?
0
Hello Hector,
You can find small demo attached.
Sincerely yours,
Vlad
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
You can find small demo attached.
Sincerely yours,
Vlad
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Hector
Top achievements
Rank 1
answered on 09 Jun 2009, 01:45 PM
Outstanding! This is an even easier implementation from your previous sample. My only other question is how do I disable selection on clicking the GridView rows because this will deselect any selection. I only want to be able to select using the CheckBox.
Thank you Vlad and all the Telerik team.
Thank you Vlad and all the Telerik team.
0
Virendra
Top achievements
Rank 1
answered on 09 Jun 2009, 10:15 PM
how will you do it,
if your column in NOT checkbox templed type
<telerik:GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox Loaded="CheckBox_Loaded" />
</DataTemplate>
</telerik:GridViewColumn.CellTemplate>
but are off native Checkbox column like
<telerik:GridViewDataColumn HeaderText="Delete?" UniqueName="Delete" />
where column's EditorSettings is CheckboxEditorSettings.
thanks
virendra
if your column in NOT checkbox templed type
<telerik:GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox Loaded="CheckBox_Loaded" />
</DataTemplate>
</telerik:GridViewColumn.CellTemplate>
but are off native Checkbox column like
<telerik:GridViewDataColumn HeaderText="Delete?" UniqueName="Delete" />
where column's EditorSettings is CheckboxEditorSettings.
thanks
virendra
0
Hector
Top achievements
Rank 1
answered on 10 Jun 2009, 01:32 PM
This is how I did it:
Page.xaml
Page.xaml.cs
Thanks Vlad, it works great!
Page.xaml
<Grid.Resources> |
<ControlTemplate x:Key="AccountTypesTemplate" TargetType="telerikGV:GridViewRow" > |
<Border x:Name="rowsContainer" Background="#FF525252" Padding="8,8,8,0" > |
<Border Background="{StaticResource Office_BlackRowBackground}" x:Name="selectedRow" |
BorderThickness="1" BorderBrush="#FF000000" > |
<Grid Width="400"> |
<Grid.RowDefinitions> |
<RowDefinition Height="30" /> |
<RowDefinition Height="30" /> |
</Grid.RowDefinitions> |
<Grid.ColumnDefinitions> |
<ColumnDefinition Width="30" /> |
<ColumnDefinition Width="55" /> |
<ColumnDefinition Width="*" /> |
<ColumnDefinition Width="60" /> |
<ColumnDefinition Width="*" /> |
</Grid.ColumnDefinitions> |
<CheckBox Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" |
Margin="5,5,5,5" Loaded="CheckBox_Loaded" > |
</CheckBox> |
<TextBlock Grid.Column="1" Grid.Row="1" Foreground="White" FontWeight="Bold" Margin="0,15,15,0" |
VerticalAlignment="Top" HorizontalAlignment="Left" Text="Phone:" /> |
<TextBlock Grid.Column="3" Grid.Row="1" Foreground="White" FontWeight="Bold" Margin="0,15,15,0" |
VerticalAlignment="Top" HorizontalAlignment="Left" Text="Group:" /> |
<!--Cells--> |
<telerikGV:GridViewCell Grid.Column="1" Grid.Row="0" Foreground="White" FontWeight="Bold" Margin="0,15,15,0" |
VerticalAlignment="Top" HorizontalAlignment="Left" Value="{Binding Description}" Grid.ColumnSpan="4" /> |
<telerikGV:GridViewCell Grid.Column="2" Grid.Row="1" Foreground="White" FontWeight="Bold" Margin="0,15,15,0" |
VerticalAlignment="Top" HorizontalAlignment="Left" Value="{Binding Value}" /> |
<telerikGV:GridViewCell Grid.Column="4" Grid.Row="1" Foreground="White" FontWeight="Bold" Margin="0,15,15,0" |
VerticalAlignment="Top" HorizontalAlignment="Left" Value="{Binding GroupName}" /> |
</Grid> |
</Border> |
</Border> |
</ControlTemplate> |
<Style x:Key="rowStyle" TargetType="telerikGV:GridViewRow" > |
<Setter Property="Template" Value="{StaticResource AccountTypesTemplate}" /> |
</Style> |
</Grid.Resources> |
<telerikGridView:RadGridView Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" x:Name="gridMultiSelect_accounts" ScrollMode="RealTime" IsReadOnly="True" ShowGroupPanel="False" |
Width="400" Height="330" VerticalGridlinesBrush="Transparent" RowStyle="{StaticResource rowStyle}" |
UseAlternateRowStyle="False" AutoGenerateColumns="True" ShowColumnHeaders="False" |
MultipleSelect="True" Margin="5,5,5,5"> |
</telerikGridView:RadGridView> |
Page.xaml.cs
private void CheckBox_Loaded(object sender, RoutedEventArgs e) |
{ |
CheckBox checkBox = (CheckBox)sender; |
checkBox.SetBinding(CheckBox.IsCheckedProperty, |
new Binding("IsSelected") |
{ |
Mode = BindingMode.TwoWay, |
Source = checkBox.ParentOfType<GridViewRow>().Record |
}); |
} |
Thanks Vlad, it works great!
0
Jonx
Top achievements
Rank 2
answered on 18 Jul 2011, 09:55 AM
For people using that code, note that the Record class is no more. Just remove Record from the code:
private
void
CheckBox_Loaded(
object
sender, RoutedEventArgs e)
{
CheckBox checkBox = (CheckBox)sender;
checkBox.SetBinding(CheckBox.IsCheckedProperty,
new
Binding(
"IsSelected"
)
{
Mode = BindingMode.TwoWay,
Source = checkBox.ParentOfType<GridViewRow>()
});
}