[FIXED] [#1315] [4.1.0] Incorrect parameter order/count on TreeStroe.load Listeners handler function

  1. #1

    [FIXED] [#1315] [4.1.0] Incorrect parameter order/count on TreeStroe.load Listeners handler function

    hi there,

    i checked what to do to upgraded our project to Ext.net 4 and i found out that the parameter order and count of the TreeStore.load Listener (using Handler) is incorrect

    <Listeners>
        <Load Handler="console.log('Load.handler()'); for (i = 0; i < arguments.length; i++) { console.log(arguments[i]);}" />
    </Listeners>
    produces the following java script code

    listeners: {
        load: {
            fn: function(item, node, records, successful, options) {
                console.log('Load.handler()');
                for (i = 0; i < arguments.length; i++) {
                    console.log(arguments[i]);
                }
            }
        }
    }
    but it should be like this

    listeners: {
        load: {
            fn: function (item, records, successful, operation, node, eOpts) {
                console.log('Load.handler()');
                for (i = 0; i < arguments.length; i++) {
                    console.log(arguments[i]);
                }
            }
        }
    }

    here also a full examples

    <%@ Page Language="C#" %>
    
    
    <script runat="server">
        protected void NodeLoad(object sender, NodeLoadEventArgs e)
        {
            string prefix = e.ExtraParams["prefix"] ?? "";
    
            if (!string.IsNullOrEmpty(e.NodeID))
            {
                for (int i = 1; i < 6; i++)
                {
                    Node asyncNode = new Node();
                    asyncNode.Text = prefix + e.NodeID + i;
                    asyncNode.NodeID = e.NodeID + i;
                    e.Nodes.Add(asyncNode);
                }
    
    
                for (int i = 6; i < 11; i++)
                {
                    Node treeNode = new Node();
                    treeNode.Text = prefix + e.NodeID + i;
                    treeNode.NodeID = e.NodeID + i;
                    treeNode.Leaf = true;
                    e.Nodes.Add(treeNode);
                }
            }
        }
    </script>
    
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>TreePanel using PageProxy - Ext.NET Examples</title>
    
        <link href="//examples.ext.net/resources/css/examples.css" rel="stylesheet" />
        <script>
            var paramsFn = ["item", "records", "successful", "operation", "node", "eOpts"];
            var paramsHandler = ["item", "node", "records", "successful", "options", "[empty]"];
    
            var LoadHandler = function (item, records, successful, operation, node, eOpts) {
                console.log('Load.fn()');
                for (i = 0; i < arguments.length; i++) {
                    console.log('%s: %o', paramsFn[i], arguments[i]);
                }
            }
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <h1>TreePanel using PageProxy</h1>
    
            <ext:TreePanel
                ID="TreePanel1"
                runat="server"
                Title="Tree"
                Width="200"
                Height="500"
                Border="false">
                <Store>
                    <ext:TreeStore runat="server" OnReadData="NodeLoad">
                        <Proxy>
                            <ext:PageProxy />
                        </Proxy>
                        <Listeners>
                            <Load Handler="console.log('Load.handler()'); for (i = 0; i < arguments.length; i++) { console.log('%s: %o', paramsHandler[i], arguments[i]); }" />
                            <%--<Load Fn="LoadHandler" />--%>
                        </Listeners>
                    </ext:TreeStore>
                </Store>
                <Root>
                    <ext:Node NodeID="0" Text="Root" Expanded="true" />
                </Root>
                <ViewConfig LoadMask="false" />
            </ext:TreePanel>
        </form>
    </body>
    </html>
    Regards
    Paul
    Last edited by Daniil; Apr 29, 2016 at 3:46 PM. Reason: [FIXED] [#1315] [4.1.0]
  2. #2
    Hello Paul! Thanks for the report! We have checked Sencha documentation and it matches your claim!

    We have logged this under issue id #1315 in github!

    Notice that you can just
    var myHandler = function (this, records, successful, operation, node, eOpts) {
      // your code here
    };
    and then use instead of Handler=, just <Load Fn="myHandler" /> to get the correct argument list in your function!

    I hope this helps! We'll update here as soon as we fix this problem!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Fixed in the v3 and v4 sources. As for v4 the fix will be included into the upcoming 4.1.0 release.

    By the way, we don't add the eOpts argument for any events in Ext.NET (for .Handler). We might review it in the future, but so far nobody requested it. Anyways, even if it is needed it will be easy to workaround with arguments[arguments.length - 1]. It is about .Handler. As for .Fn it is not a problem at all as Fabricio demonstrated.

    Thank you for the report!

Similar Threads

  1. Replies: 8
    Last Post: Jul 12, 2013, 12:01 PM
  2. Replies: 9
    Last Post: Jun 27, 2012, 2:17 PM
  3. If else condition handler in Listeners
    By NishaLijo in forum 1.x Help
    Replies: 2
    Last Post: Jul 29, 2010, 6:20 AM
  4. [CLOSED] [1.0] Incorrect arguments for Store Add/Remove listeners
    By r_honey in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 01, 2010, 2:57 PM
  5. Replies: 0
    Last Post: Apr 14, 2009, 6:10 PM

Posting Permissions