This is a migrated thread and some comments may be shown as answers.

[Solved] findNodeByText and fincNodeByValue are missing in MVC version !!

9 Answers 128 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Martin
Top achievements
Rank 1
Martin asked on 11 Oct 2011, 10:19 AM
these two methods are missing in the MVC version :(

for how long are we supposed to hack the TreeView using jQuery selectors ???

9 Answers, 1 is accepted

Sort by
0
John DeVight
Top achievements
Rank 1
answered on 28 Oct 2011, 09:40 PM
Hi Martin,

I have a CodePlex project (http://telerikmvcextendedjs.codeplex.com/) where I have been extended the client API for the Telerik MVC controls.  I came across your forum post last night and started implementing findNodeByText() and findNodeByValue() functions for the treeview.

If you would be willing to give me feedback, I would like to work with you on implementing the same functionality that you see in the ASP.NET AJAX RadTreeView.

I've attached a sample application for you to look at.  Run the application, and on the home page, under Samples, TreeView, click on "Working with Client Side Tree Node".  The findNodeByText() and findNodeByValue() return a "Node" object with the following functions implemented:
1. select()
2. deselect()
3. selected()
4. highlight()
5. unhighlight()
6. expand()
7. collapse()

Let me know what you think and what functions would be a priority for you.  I'll be adding more functions over the weekend.

Regards,

John DeVight
telerikmvcextendedjs at gmail dot com
0
Alex Gyoshev
Telerik team
answered on 01 Nov 2011, 03:10 PM
Hi John, Martin,

We just added the findByText() and findByValue() functions. They will be available with upcoming builds.

Best wishes,
Alex Gyoshev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Paulo de Tarso
Top achievements
Rank 1
answered on 03 Nov 2011, 01:30 PM
Hi, John and Alex.

The item WikiPage.cs is missing in the project...

thank you

Paulo
0
Martin
Top achievements
Rank 1
answered on 03 Nov 2011, 01:45 PM
Hi John...

sorry, haven't had the time to look at your solution.

I hacked the MVC control using jQuery some time ago... i found most solutions and inspiration on this forum and via Google.
So i already implemented lots of functions myself:
- nodeByValue
- expandNode
- expandByNodeValue
- parentNode

and using cookies and Hashnavigation i've also created a 'persistent' tree that saves state between refresh, and ability to navigate to a node via a link ... http//..../?cat=5#node=15

but in my mind, a lot of nice api's are missing in the MVC version... so i hope that MVC controls will get more attention in the near future, especially now where Microsoft is speeding up development of MVC 4-5-6...

I'll have a look at your extensions as soon as i get time (or in the moment there is an API im missing) - i have a deadline im trying to catch :)

I'll post comments and addon's when i get the time :)
0
John DeVight
Top achievements
Rank 1
answered on 03 Nov 2011, 09:38 PM
Thanks Alex!
0
John DeVight
Top achievements
Rank 1
answered on 03 Nov 2011, 09:42 PM
Hi Paulo,

The WikiPage.cs should have been removed from the project.  My mistake!  Please try removing it from the project and if it is still causing problems, let me know...  I'll also update the project in the previous post.

Regards,

John
0
John DeVight
Top achievements
Rank 1
answered on 03 Nov 2011, 09:47 PM
Hi Martin,

I'd be very interested in the persisted tree solution.  I had a need for it as well and put together a solution that works, but is a bit of a hack.

Feel free to contact me anytime about any API's that you find would be useful.  I'm always looking for ideas to add to my little CodePlex project... =)

Regards,

John DeVight
telerikmvcextendedjs at gmail dot com
0
Martin
Top achievements
Rank 1
answered on 07 Nov 2011, 09:10 AM
Hi John

Just now i'm faced with a challenge : Deleting a node from the tree !

this is how i use Hash navigation:
http://benalman.com/projects/jquery-hashchange-plugin/

var byScript = false;
function onNodeSelected(e) {
    byScript = true;
    var nodeid = treeView().getItemValue(e.item);
    location.hash = "#node=" + nodeid; //<----- HashChange plugin
 
    getNodeContentByID(nodeid);
     
    expandNodeID(nodeid);
}
//Select a Node
function ClickNode(nodeid) {
    $("#TreeView").find(".t-input[name='itemValue'][value='" + nodeid + "']")
                  .closest("div")
                  .find(".t-in:first")
                  .trigger("click");
     
    //expand parent in case its closed
    expandNodeID(parentNode(itemByValue(nodeid)));
    expandNodeID(nodeid);
}
 
$(function () {
    // Bind the event.
    $(window).hashchange(function () {
        if (!byScript) {
            if (location.hash.indexOf("#node=") > -1) {
                ClickNode(location.hash.split("=")[1]);
            }
            /*else if ($.cookie('SelectedNode') != null) {
                ClickNode($.cookie('SelectedNode'));
            } */
            else { //selecting using serverside scripting...
                ClickNode(@(Model.CourseTree.Count > 0 ? Model.CourseTree.First().CourseTreeNodeID : 0));
            }
        }
        byScript = false;
    })
});
0
Martin
Top achievements
Rank 1
answered on 07 Nov 2011, 09:19 AM
And this is how i created the persistent tree:
Require the Cookie plugin: http://plugins.jquery.com/project/Cookie


function
onNodeSelected(e) {
        var nodeid = treeView().getItemValue(e.item)
 
        $.cookie('SelectedNode', nodeid); //<-- require the jquery cookie plugin
 
        getNodeContentByID(nodeid);
        expandNodeID(nodeid);
    }
 
    $(function () {
        // Bind the event.
        $(window).hashchange(function () {
            if (!byScript) {
                if (location.hash.indexOf("#node=") > -1) {
                    ClickNode(location.hash.split("=")[1]);
                }
            }
            byScript = false;
        })
    });
 
    $().ready(function () {
        $("#tabs").tabs({ cookie: { expires: 1} });
 
        setTimeout(function () {
            if ($.cookie("FocusTargetID") != null) {    //FocusTarget is set by a submit form
                $($.cookie("FocusTargetID")).focus(); //OnSubmit the Form will set the cookie
                $.cookie("FocusTargetID", null);      //And when the page returns, the focus is set
            }
 
            if ($.cookie('SelectedNode') != null) {
                ClickNode($.cookie('SelectedNode'));
            } else {
                byScript = false;
                $(window).hashchange();
            }
        }, 0);
    });
Tags
TreeView
Asked by
Martin
Top achievements
Rank 1
Answers by
John DeVight
Top achievements
Rank 1
Alex Gyoshev
Telerik team
Paulo de Tarso
Top achievements
Rank 1
Martin
Top achievements
Rank 1
Share this question
or