TreePanel Ajax Method Loader by code

  1. #1

    TreePanel Ajax Method Loader by code



    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.
  2. #2

    RE: TreePanel Ajax Method Loader by code

    Hi Mickna,


    Example


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


    Geoffrey McGill
    Founder
  3. #3

    RE: TreePanel Ajax Method Loader by code

    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????
  4. #4

    RE: TreePanel Ajax Method Loader by code

    Hi,

    Why do need whole node? May be pass node id only?
  5. #5

    RE: TreePanel Ajax Method Loader by code

    I need the node because inside the NodeLoad method I need information of the node.
  6. #6

    RE: TreePanel Ajax Method Loader by code

    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){...
  7. #7

    RE: TreePanel Ajax Method Loader by code

    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?

Similar Threads

  1. [CLOSED] Migrating to 2: TreePanel loader
    By PhilG in forum 2.x Legacy Premium Help
    Replies: 11
    Last Post: May 18, 2012, 3:24 PM
  2. Treepanel how to get selected node without using a Ajax event or method ?
    By lordofthexings in forum Examples and Extras
    Replies: 5
    Last Post: May 26, 2010, 12:02 PM
  3. TreePanel - load root with loader
    By pintun in forum 1.x Help
    Replies: 2
    Last Post: Apr 14, 2010, 8:19 PM
  4. Ajax Method ??
    By heysol in forum 1.x Help
    Replies: 1
    Last Post: Sep 02, 2009, 12:15 PM
  5. Replies: 5
    Last Post: May 13, 2009, 12:10 PM

Posting Permissions