PDA

View Full Version : TreePanel Ajax Method Loader by code



Mickna
Dec 08, 2009, 12:41 PM
Hi guys,

In all samples of TreePanel in the source code the part in which we create listeners is in html code, but How to do this in code??? Because my tree panel is created dinamically.

The part of html code that I need in c# code is in a big letter.



<ext:TreePanel
ID="TreePanel1"
runat="server"
Title="Tree"
AutoHeight="true"
Border="false">
<Root>
<ext:AsyncTreeNode NodeID="0" Text="Root" />
</Root>
<Listeners>
<BeforeLoad Fn="nodeLoad" />
</Listeners>
</ext:TreePanel>



Please help me.

geoffrey.mcgill
Dec 09, 2009, 12:45 AM
Hi Mickna,


Example



this.TreePanel1.Listeners.BeforeLoad.Fn = "nodeLoad";

Hope this helps.

Mickna
Dec 11, 2009, 3:28 PM
Yes, I know but if I need to have the nodeLoad method that receives another parameter for example:




[AjaxMethod]
public string NodeLoad(string nodeID Coolite.Ext.Web.AsyncTreeNode node)
{
/*******Code*********/
}

How can I do that by code????

Vladimir
Dec 11, 2009, 3:46 PM
Hi,

Why do need whole node? May be pass node id only?

Mickna
Dec 11, 2009, 3:56 PM
I need the node because inside the NodeLoad method I need information of the node.

Vladimir
Dec 11, 2009, 4:11 PM
Hi,

Then pass required information as additional arguments. Javascript TreeNode object is very comples (for example, contains reference on parent tree) and can't be automatic serialized (even if it is possible then why is required to pass such huge information to server). Use simple objects


1.
Coolite.AjaxEvents.MyMethod(Ext.encode({Id: node.id, Text: node.text}))
2.
public class SimpleNode{ public string Id{...} public string Text {...}}
3. AjaxMethod:
public void MyMethod(SimpleNode node){...

ljankowski
Jan 05, 2010, 11:34 PM
This is how I load my treenodes as well, and it works great, but I have a question. Is it possible to page the results when using this method, and how would you go about doing that?