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

RowReorderBehavior is not working with Grouped GridView

0 Answers 71 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.
Nikhil Thaker
Top achievements
Rank 1
Nikhil Thaker asked on 10 May 2012, 06:53 AM

I am trying to use RowReorder code provided by Telerik, which is working fine in normal case. But when

I am grouping the Grid, the code provided is simply not working. Following is the code block which

actually takes care of Reordering of Rows in "OnDropInfo"...

else if (e.Options.Status == DragStatus.DropComplete && gridView != null)
            {
                IList items = gridView.ItemsSource as IList;
                GridViewRow row = this.AssociatedObject.ItemContainerGenerator.ContainerFromItem
(this.currentDropItem) as GridViewRow;
                DropPosition dropPosition = this.GetDropPositionFromPoint(e.Options.CurrentDragPoint,
row);
                int index = 0;
                if (row != null)
                {
                    index = items.IndexOf(row.Item);
                    if (dropPosition == DropPosition.After)
                    {
                        index++;
                    }
                    if (index < 0)
                    {
                        index = 0;
                    }
                }
                foreach (object draggedItem in draggedItems)
                {
                    items.Insert(index, draggedItem);
                }
            }

Problem here is the ItemSource dosent have knowledge of Row Index in grid after Grouping..which I can get using GridView.Items property but when I am trying to insert using "GridView.Items.Insert(index, object)", its throwing the "InvalidOperationException" with Follwing Message...

"Operation is not valid while ItemsSource is in use. Access and modify elements with ItemsControl.ItemsSource instead."

Please let me know how I can handle the scenario of using RowReorderBehavior with Grouped GridView.

Tags
GridView
Asked by
Nikhil Thaker
Top achievements
Rank 1
Share this question
or