Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1940
WebDataTree with WebDataMenu, ClientEvent NodeClick causing javascript error
posted

Hello,

I tried to build in a WebDataMenu into our WebDataTree which normally was used to just select an item, postback the page with AutoPostBack-NodeClick on and load some stuff on the server to refresh controls...

Now I was running into problems, but I seem to have solved them by avoiding using client and server events (NodeClick) at the same time, as I now just use client events which themselves postback the page if nessasary.

the result is this:

 

<script language="javascript" type="text/javascript">

<!--

    var lastNode = null;

    var menuClick = false;

 

    function treeWebDataMenu_ItemClick(menu, eventArgs) {

        menuClick = true;

        switch (eventArgs.getItem().get_key()) {

            case "makeTemplate":

                if (lastNode != null) {

                    __doPostBack('makeTemplate', lastNode.get_valueString());

                }

                break;

            case "delete":

                if (lastNode != null) {

                    __doPostBack('delete', lastNode.get_valueString());

                }

                break;

        }

    }

 

    function webDataTree_NodeClick(tree, eventArgs) {

        lastNode = eventArgs.getNode();

 

        var menu = $find("<%= treeWebDataMenu.ClientID %>");

 

        if (menu != null && eventArgs.get_browserEvent() != null && eventArgs.get_browserEvent().button == 2) {

            menuClick = false;

            menu.showAt(null, null, eventArgs.get_browserEvent());

        } else {

            if (lastNode != null && menuClick == false) {

                menuClick = false;

                __doPostBack('select', lastNode.get_valueString());

            }

        }

    }

 

// -->

</script>

<ig:WebDataTree ID="webDataTree" runat="server" SkinID="WorkplaceTree" SelectionType="Single">

    <%--OnNodeClick="NodeClicked"--%>

    <%--<AutoPostBackFlags NodeAdded="On" NodeClick="On" />--%>

    <DragDropSettings EnableDragDrop="True">

    </DragDropSettings>

    <ClientEvents NodeClick="webDataTree_NodeClick" />

</ig:WebDataTree>

<ig:WebDataMenu ID="treeWebDataMenu" runat="server" Style="margin-bottom: 0px" IsContextMenu="True">

    <Items>

        <ig:DataMenuItem Text="Als Vorlage verwenden" Key="makeTemplate">

        </ig:DataMenuItem>

        <ig:DataMenuItem Text="Löschen" Key="delete">

        </ig:DataMenuItem>

    </Items>

    <ClientEvents ItemClick="treeWebDataMenu_ItemClick" />

</ig:WebDataMenu>

 

 

------------------

everything is working as indented, BUT sometimes and really irregular I get this javascript error in the set_activeNode function:

 

_activeNode seems not to be what is expected at this point, but why?

the error says "_activeNode" does not support function "get_sytleElement()".

I can not 100% reproduce this error, i just comes up after 2-20 clicks in no obvious order or pattern. :(

thanks for reading :)

any help?

 

Carsten