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

Expand on Drop not working server-side

4 Answers 119 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Gary Davis
Top achievements
Rank 2
Gary Davis asked on 31 Jul 2008, 06:45 PM

When I drag a file node onto a folder node, I want the folder node expanded on the PostBack display.

On drop, the NodeDrop server event fires. I update my database table then set e.DestDragNode.Expanded to true (a breakpoint shows it was true anyhow). BTW, on PageLoad, I do not re-databind if IsPostBack.

I use the NodeDataBind event and this seems to fire even when IsPostBack is true. This fires after the NodeDrop and at this point, the Expanded property is false.

Is the NodeDataBind interfering with this property setting or am I missing something? Do I need client-side support for this? I don't think so since if I breakpoint within the NodeDataBind and manually set a few folder nodes Expanded property to true, they do display expanded when continuing from the breakpoint.

This is the control:

<telerik:radtreeview id="radTree" runat="server"
 allownodeediting="True"
 datafieldid="RowID"
 datafieldparentid="ParentID"
 datasourceid="sqlDataSourceCustomerContent"
 datatextfield="ContentID"
 datavaluefield="RowID"
 enabledraganddrop="True"
 multipleselect="True"
 onclientcontextmenuitemclicking="onClientContextMenuItemClicking"
 onclientdoubleclick="onClientDoubleClick"
 oncontextmenuitemclick="radTree_ContextMenuItemClick"
 onnodedatabound="radTree_NodeDataBound"
 onnodedrop="radTree_NodeDrop"
 onnodeedit="radTree_NodeEdit"
 skin="Outlook">
   [.... context menus ....]
 <CollapseAnimation Type="OutQuint" Duration="100"></CollapseAnimation>
 <ExpandAnimation Type="OutQuart" Duration="100"></ExpandAnimation>
</telerik:radtreeview>

Also, it would be nice if all currently expanded nodes remained expanded.

Can I wrap this in an Ajax panel so the "drop" postback is handled without the page-redisplay?

Thanks,
Gary Davis

4 Answers, 1 is accepted

Sort by
0
Gary Davis
Top achievements
Rank 2
answered on 31 Jul 2008, 08:51 PM
To answer my own last question, wrapping a RadAjaxPanel around the treeview worked nicely to hide the postback. However, it still comes back with the tree completely collapsed.
0
Atanas Korchev
Telerik team
answered on 01 Aug 2008, 06:09 AM
Hello Gary Davis,

For some reason your treeview is databound again after performing drag and drop. Hence all nodes render collapsed again.

Regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Gary Davis
Top achievements
Rank 2
answered on 04 Aug 2008, 01:48 PM
I checked my code and actually, I never do any databind calls to the treeview. I think the binding is done by the control behind the scenes based on the properties set on the control:

  •  datafieldid="RowID"
  •  datafieldparentid="ParentID"
  •  datasourceid="sqlDataSourceCustomerContent"
  •  datatextfield="ContentID"
  •  datavaluefield="RowID"

This works out well except for the postback case where I don't want the re-databind to take place.

Any ideas?

Thanks,
Gary Davis

0
Gary Davis
Top achievements
Rank 2
answered on 04 Aug 2008, 02:36 PM
Problem solved.

I read another posting about the unexpected databind due to modifying the SqlDataSource SelectCommand property. In my case, I was not modifying the SelectCommand but was modifying the UpdateCommand/InsertCommand/DeleteCommand properties in certain situations. I changed the TreeView's DataSource, removing the Update/Insert/Delete statements and only leaving the Select.

I then created a 2nd SqlDataSource with the removed statements and updated the code to use the new ID and now I am not getting the unexpected DataBind which caused the tree collapse.

Thanks,
Gary Davis
Tags
TreeView
Asked by
Gary Davis
Top achievements
Rank 2
Answers by
Gary Davis
Top achievements
Rank 2
Atanas Korchev
Telerik team
Share this question
or