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

SelectionMode="Extended" + EditTriggers="CellClick" => More than edited row is selected

1 Answer 93 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Arthur
Top achievements
Rank 1
Arthur asked on 28 Nov 2014, 02:50 PM
Hi,

if I set SelectionMode to "Extended" and EditTriggers to "CellEdit" and afterwards I select two rows and start to edit a cell in one of the two selected rows, the selection is not reduced to the edited row. Bug?

1 Answer, 1 is accepted

Sort by
0
Boris
Telerik team
answered on 01 Dec 2014, 05:06 PM
Hello Arthur,

By design selecting multiple items and then starting to edit one of them does not clear the other selected items. However, if you need such a functionality, you can easily implement it by using the BeginningEdit event as follows:

public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
 
            this.clubsGrid.BeginningEdit += clubsGrid_BeginningEdit;
        }
 
        void clubsGrid_BeginningEdit(object sender, GridViewBeginningEditRoutedEventArgs e)
        {
            var gridView = sender as RadGridView;
            var businessObject = e.Cell.DataContext as Club;
            var itemsToUnselect = gridView.SelectedItems.Where(item => !item.Equals(businessObject)).ToList();
            var selectedItemsCount = itemsToUnselect.Count;
 
            for (int index = 0; index < selectedItemsCount; index++)
            {
                if (gridView.SelectedItems[index].Equals(businessObject))
                {
                    gridView.SelectedItems.Remove(gridView.SelectedItems[index]);
                }
            }          
        }
    }


I attached a sample project that demonstrates the suggested approach.

I hope this helps.


Regards,
Boris
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
Arthur
Top achievements
Rank 1
Answers by
Boris
Telerik team
Share this question
or