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

Drag and Drop Problem - View out of sync with bound Datatable

2 Answers 142 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Markus Giera
Top achievements
Rank 1
Markus Giera asked on 08 Apr 2010, 11:48 PM

Dear Telerik Users

I'm having a problem with drag and drop functionality in a hierarchical Gridview.
As I drag rows and drop them on top of another row, the underlying (datasource-bound) datatable-entries get updated (Datarow["ParentId"] = dropCell["ParentId"].
This means, that after dragging, the entries appear under another parent in hierarchy. The gridview has to reflect these changes in the underlying database by adjusting the size of the expanded hierarchy-grid.
Even thought in general it's working, but there are a lot of incoherencies,
- expand/collapse is running out of sync
- parents with children sometimes cannot be expanded
- the children of the last row in the mastertemplate never shows the children even though expanded (children are "hidden")

closing and reopening the gridview solves the out-of-sync issues until I restart drag and dropping + expanding and collapsing

Question:
What is the "official way" of keeping the underlying datatables and the visual elements syncronized?
I've tried:
1. Datatable.AcceptChanges()
2. DataRow.BeginEdit() - EndEdit()
3. dropTemplate.Update(GridUINotifyAction.... ==> every action)
4. RadGridView.Update() RadGridview.Refresh()
The only effect I've noticed is that the "GridUINotifyAction.AddRows" seems to adapt the size of the expanding parent.

Sorry, maybe it's a trival mistake, but I do not see it and I'm almost there...

Thank you.

Markus

 

 

 

2 Answers, 1 is accepted

Sort by
0
Markus Giera
Top achievements
Rank 1
answered on 09 Apr 2010, 10:11 AM
Dear Telerik Users

Update:
The Problem is not resulting from the database Layer but from the visual update logic.
I've solved the problem with this code.
void radHView1_ChildViewExpanded(object sender, ChildViewExpandedEventArgs e)  
        {  
            foreach (KeyValuePair<int, GridViewTemplate> kvp in _templateDict)  
            {  
                kvp.Value.Update(GridUINotifyAction.ExpandedChanged);  
                kvp.Value.Update(GridUINotifyAction.RowCountChanged);  
                kvp.Value.Update(GridUINotifyAction.BatchDataChanged);  
            }  
        } 
I actually had another mistake in the ChildViewExpanded Handler. Instead I had a "ChildViewExpanING" Handler.
While creating the templates for the variable numbers levels in hierarchy, I add them to a dictionary. So I don't have to use recursion for the update of each.
Great product, good company! but you have to really get into the underlying logic.

Greets

Markus
0
Martin Vasilev
Telerik team
answered on 14 Apr 2010, 01:22 PM
Hello Markus Giera,

I am glad that you managed to find a solution for your issue. Probably, you would like to take a look at the following KB Article. It contains directions and an example of how to implement Drop And Drag scenario.

Let me know if you have any additional questions.

All the best,
Martin Vasilev
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
Markus Giera
Top achievements
Rank 1
Answers by
Markus Giera
Top achievements
Rank 1
Martin Vasilev
Telerik team
Share this question
or