Showing posts with label beta. Show all posts
Showing posts with label beta. Show all posts

Wednesday, March 28, 2012

TreeView and UpdatePanel - Beta 2

I believe the documentation states the treeview is not supported in an UpdatePanel but has anyone manged to make it work? There have been a bunch of posts that seem to indicate some success. I have a treeview driving a formview in an UpdatePanel. To make things work I think I just have to stop the SelectedNode from causing a postback and then wire up some javascript to "call" the UpdatePanel around the formview. Or is support for a treeview in a UpdatePanelimminent?

Thanks in advance

I have tried asp:TreeView and asp:UpdatePanel in the latest Ajax and find we can get the selected node of a TreeView in a asp:UpdatePanel.You can use a TreeView to drive a FormView in a asp:UpdatePanel.
Here are some sample codes for your reference.
HTML code in .aspx

Treeview ExpandAll problem in beta 1, 2 with EnableClientScript="true"

I have a treeview problem inside an update panel since the first beta. In the last ctp no problem at all.

I have a treeview in the updatepanel with EnableClientScript="true". I have two button in the same update panel, that calls ExpandAll, and CollapseAll in server side click events. That works as expected: the updatepanel refresh the treeview with all node collapsed/expanded. However after then when I expand one node (that not cause a postback yet), and select a node (which now cause a postback), the nodes collapsed/expanded randomly after the updatepanel refresh.

It seems that the server side ExpandAll/CollapseAll could be out of the sync with the client side node expanding/collapsing.

It seems to me when EnableClientScript="true" for a treeview, the tree maintain the expanded/collapsed node in hidden fields, and that hidden field could be out of the sync after a server side ExpandAll/CollapseAll.

?

I write a small javascript function which collapse or expand all node on the cilent side for the treeview. Even the nodes collapsed state is persisted during postbacks/partial postbacks.

The bug still exist, but I will not use the server side ExpandAll in the future...

(just found by the docs that the treeview is not supported in the updatepanel officially, but many of us using it without main problems)

treeview in Multiview clientscript problem in new beta

Hi,

I have a problem with one of my web page... for debugging purpose I created a simple test webpage to explain the problem.
Here it is:
An updatepanel containing a multiview.
In this multiview there's 2 view, each containing a tree view and a button to go to the other view.
The default activeview is the first one.

My problem is that only the treeview in the first view works.
The treeview in the 2nd view crashes with error "Microsoft JScript: 'TreeView2_Data' is undefined." when I click a node.
Of course if I set the enableclientscript property of the treeview to off then it works okay but it does a partial postback at each node collapse-expand...

My guess is that the clientscript is not injected correctly on view change but how can I fix that ?
Btw it used to work before I updated to Beta 1.0

Thanks a lot !

Jean-Sébastien Roy

I was able to repro it and report it to the developer..

thanks for the report....

Andres


Hi,

The TreeView control is not supported inside UpdatePanels in Atlas 1.0. A future release of Atlas will support this scenario. In Atlas 1.0 you can have the TreeView outside the UpdatePanel.

Thanks,

Eilon


Thanks to you both for the fast answers !

Placing a TreeView inside an UpdatePanel is not supported on the Beta. Please look a the following documentation page (under the "UpdatePanel Compatible Controls"):http://ajax.asp.net/docs/Overview/intro/partialpagerendering/updatepanelOverview.aspx. Full support for all controls will be available on the next release of ASP.NET.

Thanks,
Federico


I had a same problem. Seems like its not supported in Beta version. Does anyone know of a workaround?

Thanks


Hi,

UpdatePanel control is used for only partial updating/partial_page rendering. You can not use the updatePanel control for Treeview and someother controls like MenuView and FileUpload.

If you need more help on this check in below link under UpdatePanel Control.

http://ajax.asp.net/default.aspx

Pradeep Kumar

Treeview in Updatepanel gets lost when selecting node

We moved to the Beta and then our treeviews in updatepanels started acting strangely. Especially when a node was selected in a treeview that was populated in code after the first page load. It "randomly" collapses and expands nodes as you select a node. Its like its viewstate is messed up or ...

This behavior doesn't occur if the whole treeview i expanded when finished populating it. But it doesn't look so good if it's all expanded. Does anyone know how to collapse all nodes client side ? Cause that might be a workaround - serverside expand all nodes after populating and then clientside collapsing them - server side collapsing gives the random behaivor back !

I read some articles about how the treeviews scripts aren't registered in the scriptmanager which is required in Beta 1. And how treeviews i update panels aren't supported since the rarely are used that way. But the app doesn't look so good when a frequently used treeview causes a full postback of the page just to select a node - which Atlas updatepanel handled great and pretty quick in the AJAX Beta it doesn't work as well at all and is much slower.

Does anyone have the same problem or better yet a workaround while waiting for AJAX updatepanel supporting a treeview

We are having the same problem with the RC release. I didn't try it with other releases.

I use this script to open/close the treeview, with a little adjustment it should work for you too. Hope it helped

function

CloseTree(treeId)

{

//childnodes are contained in divsvar subDivs = document.getElementById(treeId).getElementsByTagName("div");for (i=0; i<subDivs.length; i++)

{

//tree lines are images contained in divs also, so we don't hide them because they will not be shown when the node is toggled into viewif (subDivs[i].id.length >0)

{

subDivs[i].style.display =

'none';

}

}

var imgs = document.getElementById(treeId).getElementsByTagName("img");for (j=0; j<imgs.length; j++ )

{

if ( imgs[j].alt.indexOf("Collapse") >=0 )

{

imgs[j].src = <%=

"'" + Page.ResolveURL("~/") +"'"%>+"Images/tree_collapsed.gif";

imgs[j].alt = imgs[j].alt.replace(

"Collapse","Expand");

}

}

}

function OpenTree(treeId)

{

//childnodes are contained in divsvar subDivs = document.getElementById(treeId).getElementsByTagName("div");for (i=0; i<subDivs.length; i++)

{

subDivs[i].style.display =

'block';

}

var imgs = document.getElementById(treeId).getElementsByTagName("img");for (j=0; j<imgs.length; j++ )

{

if ( imgs[j].alt.indexOf("Expand") >=0 )

{

imgs[j].src = <%=

"'" + Page.ResolveURL("~/") +"'"%> +"Images/tree_expanded.gif";

imgs[j].alt = imgs[j].alt.replace(

"Expand","Collapse");

}

}

}


I have the same issue. Were you able to resolve it? Would appreciate any feed back.

Grewal.

Monday, March 26, 2012

Treeview not working in Beta 1.0?

I have a treeview that used to work in CTP July version but stopped working after I installed the beta version.

The first problem: say I have node A and it has at least one child. If I expand node A (by clicking the + button) then click on the name of the node, it readds the children, effectively doubling the number of the nodes. I could continue adding the children of the nodes resulting is multiple children being added.

The second problem relates to the first one. Expand node A, expand node B, select node B then select one of node B's child. Somehow one of node A's child is expanded.

The third one: I can't expand more than two levels. Everytime I try to do it, this error message appears:

Line: 82
Error: 'undefined' is null or not an object

Looking at source, the line that breaks it is this:

table.insertAdjacentHTML("afterEnd", chunk);

All of the nodes have PopulateOnDemand = true. Am I doing something totally wrong or is it really a bug in the beta 1.0? Every other controls (including the ones from value pack) seems to work properly except this treeview. :(

For reference here's what I have on the aspx page:

<div class="BrowserTreeView">
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TreeView ID="tvDirectory" runat="server" OnTreeNodePopulate="PopulateNode" OnPreRender="tvDirectory_PreRender" OnSelectedNodeChanged="tvDirectory_SelectedNodeChanged" SkinID="Explorer"></asp:TreeView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostbackTrigger ControlID="cmbComputer" EventName="SelectedIndexChanged"></asp:AsyncPostbackTrigger>
<asp:AsyncPostbackTrigger ControlID="cmdOpen" EventName="Click"></asp:AsyncPostbackTrigger>
</Triggers>
</asp:UpdatePanel>
</div>

Please see these two articles:

- What's up with UpdatePanels and how come nothing works? (http://forums.asp.net/thread/1440058.aspx)
This is a higher level piece that explains how UpdatePanel changed from being automatic (and broken) in the CTP to the new functionality in the beta.

- HOWTO: Write controls compatible with UpdatePanel without linking to the ASP.NET AJAX DLL (http://forums.asp.net/thread/1445844.aspx)
This article goes in depth on how to use the new registration APIs on ScriptManager, but without linking to the Atlas assembly.

Thanks,

Eilon


Thanks. I didn't know that treeview is not supported yet.

Treeview TreeNodePopulate event.

I have recently installed the AJAX Beta 2 Extensions having used the ATLAS CTP. Having installed it I removed the DLLs from the Bin directory. On two of my pages in the application I am using the Treeview controls which only populate child nodes when each of the parent nodes are clicked on. On one page this the treeview works fine and populates on demand -

1protected void ATreeview_TreeNodePopulate(object sender, TreeNodeEventArgs e)
2 {
3switch (e.Node.Depth)
4 {
5case 0:
6break;
7case 1:
8 PopulateTreeview(e.Node);
9break;
10 }
11 }


The PopulateTreeview method takes the node that should be populated (which for e.g. is the Category) and creates all the product nodes. At the moment the TreenodePopulate event does nothing as I just want to see whether it actually raises the event. When I discovered the problem I took out all the code in this event. The code at the moment is as follows:

1protected void ATreeview_TreeNodePopulate(object sender, TreeNodeEventArgs e)
2 {
3 lblMessage.Text ="inside the treenode populate " + e.Node.Depth.ToString();
4 lblMessage.Visible =true;
5 }

When I debug this and expand a node I get the following error:


"Microsoft JScript runtime error: 'ctl00_ContentPlaceHolder1_tvUsersNoGroup_Data' is undefined" - I have no choice but to press Break and stop the application from running. In the IDE it just highlights this line TreeView_PopulateNode(ctl00_ContentPlaceHolder1_ATreeview_Data,1,ctl00_ContentPlaceHolder1_ATreeviewn1,ctl00_ContentPlaceHolder1_ATreeviewt1,null,'t','A Category','TopNode\\3016','f','','tf')

The design source code is as follows:

<asp:UpdatePanel ID="upUsers" runat="server"> <ContentTemplate> <table border="0" class="report_treeview"> <tr style="background-color:#6178BE; color: #FFFFFF;font-weight:bold; font-size:80%;text-align:center;"> <td>Users not in selected security group</td> <td><asp:DropDownList ID="ddSecurity" runat="server" AppendDataBoundItems="True" AutoPostBack="true" OnSelectedIndexChanged="ddSecurity_SelectedIndexChanged"> <asp:ListItem Selected="True" Text="Please select a security group" Value="0"></asp:ListItem> </asp:DropDownList></td> <td>Users in selected security group</td> </tr> <tr> <td style="vertical-align: top; width: 300px; text-align:left;"> <asp:TreeView id="ATreeview" runat="server" showlines="true" visible="false" OnTreeNodePopulate="tvUsersNoGroup_TreeNodePopulate"></asp:TreeView> </td> <td style="border-right: solid 1px #DDDDDD;border-left: solid 1px #DDDDDD;text-align:center;"> <asp:Button ID="btnAddUser" runat="server" Text=">>" CssClass="option_button" OnClick="btnAddUser_Click" ToolTip="Add selected users." /> <p /> <p /> <asp:Button ID="btnRemoveUser" runat="server" Text="<<" CssClass="option_button" OnClick="btnRemoveUser_Click" ToolTip="Remove selected users." /> </td> <td style="vertical-align: top; width: 300px; text-align:left;"> <asp:Label ID="lblStatus" runat="server"></asp:Label></td> </tr> </table> <p /><asp:Label ID="lblMessage" runat="server" CssClass="labelStatus"></asp:Label> </ContentTemplate> </asp:UpdatePanel>
Anyone else come across this problem? Why is my other page fine and this page is throwing this error?

I did have something like this. I would get an error on the source code saying it the object was undifined when it was trying to put the tooltip on the treenode. To 'fix' it I turned off script debuging on my browser, and it went away.

It may be something to try

Eric Wild


Thanks for the suggestion but I don't think that the problem can be solved by suppressing the errors from the browser.

What I would like to know is if other people have had the same problems as myself.

Is this a problem with the AJAX Beta 2? or my silly code?


I am encountering this issue right now and know it is related to the Visible="false" on the TreeView.

I'm using RC1 and have a Button in an UpdatePanel and a TreeView in another UpdatePanel. The TreeView has it's Visible property = "false".

When the Button is clicked, it sets TreeView's Visible="true".

At this point, if you try to Expand a TreeView Node, it will come back with that same debugging trap you encountered. I tried using Fiddler to see if it passed anything, but it didn't.

You could either keep the TreeView's Visible property = "true" from the start or set the TreeView's EnableClientScript="false".

I think this deserves a bump and hope someone can further explain why and perhaps offer a workaround because the concept that the TreeView only populates its expanding Node is very nice.

Nathan

treeview updatepanel problem

hi,

i have a treeview inside an updatepanel. I'm using ajax ext beta 1

the treeview make use of the node expand with PopulateOnDemand = True

when i select a leaf node the treeeview is regenerated with one or more node that i have not added and than stop working.

I think this is a problem of the treeview with updatepanel because if I remove the updatepanel the treeview work fine.

can anyone help me to solve the problem?

thanks

this is the source code...

Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.LoadIf Not Page.IsPostBackThen trv1.Nodes.Clear() trv1.Nodes.Add(New XTreeNode("Root node","A")) trv1.Nodes(0).ChildNodes.Add(New XTreeNode("trv1_node 1","1.1")) trv1.Nodes(0).ChildNodes.Add(New XTreeNode("trv1_node 2","1.2"))'trv1.Nodes(0).ChildNodes(0).Select() trv1.Nodes(0).ChildNodes(0).PopulateOnDemand =True trv1.Nodes(0).ChildNodes(0).SelectAction = TreeNodeSelectAction.Expand trv1.ExpandDepth = 1End If End Sub Protected Sub trv1_TreeNodePopulate(ByVal senderAs Object,ByVal eAs System.Web.UI.WebControls.TreeNodeEventArgs)Handles trv1.TreeNodePopulateDim pNodeAs TreeNode = e.NodeDim pNewNodeAs TreeNode =New TreeNode("New Node","NN") pNewNode.PopulateOnDemand =True pNewNode.SelectAction = TreeNodeSelectAction.Expand pNode.ChildNodes.Add(pNewNode)End Sub

i've tried also the beta 2 but the problem remains the same!!

can anyone help me to solve the problem?


I heard it isn't supported with the Betas or RC, but I heard it may be eventually... I did work before the Betas though.