|
Rank: Newbie Groups: Member
Joined: 11/30/2011 Posts: 8
|
Hi Guys, I have made use of your trial controls (for now) to develop a WebPart which runs on SharePoint 2010. The controls are used within a User Control (which forms the basis of the WebPart). I want to capture the ItemMoved event but it is not firing. Initially I tried my own implementation and then I copied what you did in the sample - still no success. Here is the HTML code in my ascx file:
Code: HTML/ASPX
<eo:callbackpanel id="CallbackPanel1" runat="server" Triggers="{ControlID:Button1;Parameter:},{ControlID:Button2;Parameter:}">
<eo:TreeView id="tvLibraryStructure" runat="server" AllowDragDrop=true
AllowDragReordering=true ControlSkinID="None"
Width="200px" Height="200px" OnItemMoved="TreeView1_ItemMoved"
OnItemClick="Button1_Click"
onload="TreeView1_ItemMoved">
</eo:TreeView>
<P>The data source is not updated until the page posts back and triggers <STRONG>ItemMoved</STRONG>
event.</P>
<P>
<asp:Button id="Button1" runat="server" Text="Post Back" OnClick="Button1_Click"></asp:Button>
<asp:Label id="Label1" Runat="server"></asp:Label></P>
<P>Click this button to repopulate the TreeView from data source to verify that the
data source has been updated.</P>
<P>
<asp:Button id="Button2" runat="server" Text="Rebind" OnClick="Button2_Click"></asp:Button>
<asp:Label id="Label2" Runat="server"></asp:Label></P>
</eo:callbackpanel>
Now I understand that you have to fire the postback via the Button1 event. When I click that button it's associated event gets fired but the ItemMoved does not. Here is the code in my ascx.cs file:
Code: C#
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ConnectToSP(); //does some SP stuff
LoadLoggedInUserDetails();
BuildColleagueList();
//Populate the EO Treeview Control with Document Library
BuildLibraryTree();
}
}
//This never gets fired
protected void TreeView1_ItemMoved(object sender, EO.Web.TreeNodeMovedEventArgs e)
{
lblStatus.Text = "This is working";
}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "Changes saved to data source at " + DateTime.Now.ToString();
}
protected void Button2_Click(object sender, EventArgs e)
{
Label2.Text = "Repopulated from data source at " + DateTime.Now.ToString();
}
Now I've tried (as you'll see) to attach that event to other events of the TreeView control still without luck! I would really appreciate some help on this! I've tried setting the RaisesServerEvent to true as well!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Your code looks correct. You may want to check whether you have view state enabled and whether there are any other code paths that would repopulate the TreeView. In both cases the "item moved" information will be lost.
If neither is the problem, please try to create a small test app that can duplicate the problem and post the code here. We will then try to run it here to reproduce the problem. As soon as we can reproduce the problem, we will be able to tell you what's wrong.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 11/30/2011 Posts: 8
|
OK let me confirm this - since this is a User Control (within a Web Part) it gets loaded into a Sharepoint page to which I don't have access to (the whole reason for the custom part). When you say that EnableViewState should be false is that on the entire aspx page on which the control lies or for the control itself? What I've noticed is also this (it might help you) firstly when I click on a node to start dragging it it opens opens the "save dialog" for me (although the drag does happen). Now my nodes are built with a NavigateUrl but I don't know if this might be a problem. Secondly when I debug my code I've seen that my WebPart page executes this method (CreateChildControls):
Code: C#
private const string _ascxPath = @"~/_CONTROLTEMPLATES/CustomWebPartProject/MyVisualWebPart/MyVisualWebPartUserControl.ascx";
protected override void CreateChildControls()
{
Control control = Page.LoadControl(_ascxPath);
Controls.Add(control);
}
as follows in the next scenarios: Scenario A. I have ViewStateMode="Inherit" on the control and EnableViewState="false" on the WebPart zone within the aspx page (where the ascx control lies) I also have the callbackpanel triggers set to the TreeViewinitially when the page on which the part lies is loaded but also everytime I do a drag and drop. The treeview disappears thereafter. No event seems to fire Scenario B. I have ViewStateMode="Inherit" on the control and EnableViewState="true" on the WebPart zone within the aspx page (where the ascx control lies) I also have the callbackpanel triggers set to the TreeViewSame thing as in A I can possible give you guys remote access to my development machine if that would help?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
NavigateUrl might be the problem for you. NavigateUrl and server event NEVER work together. This is because in order for a server event to fire, the page must post back (to the same page), while NavigateUrl always does a free reload of the new page. For this reason, NavigateUrl and server event are mutually exclusive by nature. You can try to clear NavigateUrl to see whether that fixes the problem. We can then go from there.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 11/30/2011 Posts: 8
|
OK that seems to have solved the problem. Thanks so much for the help! Now there is a new issue. I populate the TreeView with a custom function that adds Nodes to it. For some reason however e.OldParent (on the drag event) seems to stay null no matter what. That goes for e.Node.ParentNode as well. The text values show up (which I set in my menthod) Do I need to explicitly set ParentNode (of type Node) when populating the treeview!?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
That behavior is by design for performance reason. When the TreeView is populating on demand, it ONLY passes an island node back to you. It does not pass the whole tree back and forth (because the whole tree can get quite big). As such, you should only rely on the node that is passed back to you to generate new child nodes. For example, you can store a recordID in the TreeNode's Value property and then rely solely on that value to generate new nodes.
Thanks!
|
|