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

Bug, or works as designed? SelectColumn issue...

1 Answer 31 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Todd Davis
Top achievements
Rank 1
Todd Davis asked on 17 May 2010, 09:09 PM
Consider the code below. When you run it, it displays a GridView of colors, with a select column. In this demo, the SelectColumn doesn't "do anything", but let's assume that it will later. Run the demo, and click the CheckBox next to the first item, which is Red. Now, click the Delete button. The row that Red is in goes away, as it should. However, the CheckBox remains, and now Orange is selected.

Orange is not the row I selected however. When Red row was deleted, I expected the Selected CheckBox to go away with it?

<UserControl x:Class="TestGridSelection.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:telerikGrid="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView" mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
    <Grid x:Name="LayoutRoot"
        <StackPanel Orientation="Vertical"
            <telerikGrid:RadGridView x:Name="radGridView" AutoGenerateColumns="True" SelectionMode="Extended"
                <telerikGrid:RadGridView.Columns> 
                    <telerikGrid:GridViewSelectColumn /> 
                </telerikGrid:RadGridView.Columns> 
            </telerikGrid:RadGridView> 
            <Button Content="Delete First Item" Click="Button_Click" /> 
        </StackPanel> 
    </Grid> 
</UserControl> 

using System.Collections.ObjectModel; 
using System.Windows; 
using System.Windows.Controls; 
 
namespace TestGridSelection 
    public partial class MainPage : UserControl 
    { 
        private ObservableCollection<string> _colors; 
 
        public MainPage() 
        { 
            InitializeComponent(); 
            Loaded += MainPage_Loaded; 
        } 
 
        private void MainPage_Loaded(object sender, RoutedEventArgs e) 
        { 
            _colors = new ObservableCollection<string> {"Red""Orange""Blue""Green""Yellow"}; 
            radGridView.ItemsSource = _colors; 
        } 
 
        private void Button_Click(object sender, RoutedEventArgs e) 
        { 
            _colors.RemoveAt(0); 
        } 
    } 

1 Answer, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 19 May 2010, 09:44 AM
Hi Todd Davis,

This behavior is observed because RadGridView is synchronizing its CurrentItem with its SelectedItem. When you delete the first row the next available row is designated as current and automatically this new current item is set as selected. 

Setting IsSynchronizedWithCurrentItem to false will resolve the problem.


Sincerely yours,
Milan
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
Todd Davis
Top achievements
Rank 1
Answers by
Milan
Telerik team
Share this question
or