Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treeview event not working metro 4 #1143

Closed
Gurucharan opened this issue Jul 19, 2018 · 17 comments
Closed

Treeview event not working metro 4 #1143

Gurucharan opened this issue Jul 19, 2018 · 17 comments

Comments

@Gurucharan
Copy link

Gurucharan commented Jul 19, 2018

The below code is for metro 3 and working fine. Not working in metro 4 because of backward compatibility issues. Please guide me to work with treeview in metro 4.

html.txt

Javascript

bankingQ.events.on(document, 'treeNodeToggled', 'contextItem', function (e, expanded) {

        if (event.target.parent != ".node") {
            var targetNode = event.target.offsetParent;
            var customerId = $(targetNode).attr('customerId');
            var customerType = $(targetNode).attr('customerType');
        }
        else {
            var targetNode = event.target.parentNode;
            var customerId = $(targetNode).attr('customerId');
            var customerType = $(targetNode).attr('customerType');
        }

        if (expanded) {
            $(targetNode).removeClass('collapsed');

            if (customerType == 2) {
                getServicesForCustomer(targetNode, customerId);
            }
            else if (customerType == 3)
                getClientsForCustomer(targetNode, customerId, false);

            event.stopPropagation();
        }
        else
            $(targetNode).addClass('collapsed');
    }, null, true);
@olton
Copy link
Owner

olton commented Jul 19, 2018

create pen on codepen.io with your problem code

@Gurucharan
Copy link
Author

Please provide the link i am new to frontend developing

@olton
Copy link
Owner

olton commented Jul 19, 2018

codepen.io

@olton
Copy link
Owner

olton commented Jul 19, 2018

Metro 4 template pen
https://codepen.io/olton/pen/WKGarN

@Gurucharan
Copy link
Author

the above link provides a nice online compiler environment. but where to find the solution for my problem.
in my previous code metro 3 tree used .lead.active to find the active node. but how to implement the same functionality in metro 4.
metro 4 documentation provided only the html codes.
kindly help me in this issue.

@Gurucharan
Copy link
Author

Can you provide a simple treeview example tutorials in metro 4

@olton
Copy link
Owner

olton commented Jul 20, 2018

@Gurucharan
Copy link
Author

TreeViewHTML.txt
capture

Yes, I have executed the code provided in the link you have been provided above. but the result is not fine. please refer the image attached with the comment.
pls help me on this issue.

@olton
Copy link
Owner

olton commented Jul 20, 2018

https://metroui.org.ua/intro.html

Jquery required

@Gurucharan
Copy link
Author

Ok i tried. But the issue does not solved.

added

<script src="Scripts/jquery-3.3.1.min.js"></script>

@olton
Copy link
Owner

olton commented Jul 20, 2018

https://codepen.io/olton/pen/GBNeGo

code from your file

@Gurucharan
Copy link
Author

Thank you. i placed the javascript ref first and then metro ref in the next line. it works!

@olton olton closed this as completed Jul 20, 2018
@Gurucharan
Copy link
Author

How to call data-on-node-click in metro 4. some code example for js function

@olton
Copy link
Owner

olton commented Jul 20, 2018

Please read the doc on https://metroui.org.ua

For events: https://metroui.org.ua/events.html

@Gurucharan
Copy link
Author

Gurucharan commented Jul 20, 2018

Thank you I have referred the above links and implemented
data-on-node-click

how to get the which node has been clicked from the js function.

As i am new to metro and javascript there are less sources available on the net for metro. so it is little to harder for me to get things done.

@olton
Copy link
Owner

olton commented Jul 20, 2018

arguments[0] - node, arguments[1] - treeview
<ul data-role="treeview" data-on-node-click="console.log(arguments)">
or
<ul data-role="treeview" data-on-node-click="myNodeClick">

function myNodeClick(node, tree) {
    console.log(node);
    console.log(tree);
}

@Gurucharan
Copy link
Author

Thank You

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants