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

More Drag and Drop

1 Answer 36 Views
GridView
This is a migrated thread and some comments may be shown as answers.
UGH!!
Top achievements
Rank 1
UGH!! asked on 30 Mar 2011, 10:04 PM
I having a hard time getting the grid to refresh after a drag and drop on a row. I have a "displayOrder" column where on drop, it renumbers the column and save to the db. That works fine.  The grid is bound to an observable collection so it should reflect immediately.  Here's some code:

private

 

 

void RowReorder_AfterDrop() 
{

 

 

 

short

 

 

newIdx = 1;

 

foreach (var item in oSupplyRules)
{
item.DisplayOrder = newIdx++;
}

}

private void RowReorderBehavior_DragEnded(object sender, DragEndedEventArgs e)
{

 

 

 

 

 

MessageBox.Show(string.Format("Drop complete! Index: {0}"

, e.DestinationIndex));

 

var items = ((IList)e.SourceGrid.ItemsSource); 

 

 

 

 

 

using

(e.SourceGrid.Items.DeferRefresh())

{

 

foreach (var item in e.DraggedItems)

items.Remove(item); 

}

 

 

 

foreach (var item in e.DraggedItems)
{

 

if

(e.DestinationIndex < items.Count)

items.Insert(e.DestinationIndex, item); 

}

 

 

 

 

else

 

 

{

items.Add(item);

}

}

RowReorder_AfterDrop();

}

 

 

DM.Context.SubmitChanges(); e.SourceGrid.Rebind();}

Any help would be GREATLY appreciated!

 

 

 

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 05 Apr 2011, 11:05 AM
Hello UGH!!,

 Unfortunately we cannot tell just looking at this code what's going on. Do you have the same problem using plain ListBox or this is just with RadGridView?

All the best,
Vlad
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
UGH!!
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or