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

Accessing controls from different views

5 Answers 82 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Eugene
Top achievements
Rank 1
Eugene asked on 31 Mar 2010, 10:59 PM
Greetings,
    How can a control such as a treeview control be accessed from a different view file from where it is declared.  Or is this not possible?

Thanks in advance,
Eugene

5 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 01 Apr 2010, 07:23 AM
Hello Eugene,

I am not sure what you requirement is. How do you want to access the control - client or server side? Also which product are you using?

All the best,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Eugene
Top achievements
Rank 1
answered on 01 Apr 2010, 03:01 PM
Hello Atanas,
    We are using Telerik's Telerik.Web.Mvc.dll version 2010.1.309.135.  To clarify my question,  if I stored the tree variable on the server, say in a Session variable, how would I do that?  For instance,

    $.getJSON(

"/Home/GetArticle", { dtree: $('#TreeViewDiscussion') }, function(json) {...}
The above attempt causes a crash.
Or how would I store the variable in document.cookie on the client?  What is the type of the treeview object and do we need to know what it is in order to pass the variable?

Thanks in advance,
Eugene

 

0
Atanas Korchev
Telerik team
answered on 01 Apr 2010, 04:02 PM
Hi Eugene,

I still do not understand what you are trying to achieve. What do you mean by "treeview variable" ? Could you please explain why you need to access the component and store it in session? I am pretty sure there is an easier way to achieve the task at hand.

Regards,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Eugene
Top achievements
Rank 1
answered on 01 Apr 2010, 05:48 PM
Hello Atanas,
        OK.  A treeview control is defined in index.aspx as follows:

<%

= Html.Telerik().TreeView()

 

.Name(

"TreeViewDiscussion")

 

%>

The tree is populated when the application starts with the following client side binding code:

 

$.getJSON(

"/Home/LoadDiscussion", { articleNodeValue: json.ID }, function(result) {

 

 

//alert("related items: text = " + result.text + " value = " + result.value);

 

 

 

 

 

$(

'#TreeViewDiscussion').data('tTreeView').bindTo([result]);

 

});



Then, when the user radopens a window to add data to the tree, the tree needs to be updated in a javascript function on that window's page after the user clicks a submit button on that page, as follows:

 

function submitbtn() {

 

 

var $id;

 

 

var title = $('#txtTitle').val();

 

 

var msg = $('#Message_Text').val();

 

 

//alert(title + " " + msg);

 

$.post(

"/Discussion/NewPost", { txtTitle: title, Message_Text: msg }, function(str) {

 

$id = str;

});

CloseWnd();

//Close discussion dialog window

 

 

$.getJSON("/Home/LoadDiscussion", { articleNodeValue: $id }, function(result) {

 

 

var dtree = result.dtree;

 

 

var artID = result.ArticleID;

 

alert(artID);

???.data(

'tTreeView').bindTo([result]);

 

});

}

In order to do this, the tree object is needed where the ??? are placed in the above code.  How do I get that object; it is not defined on this page.  Or is there a better way to accomplish this?

Sincerely,
Eugene 




0
Atanas Korchev
Telerik team
answered on 02 Apr 2010, 08:10 AM
Hi Eugene,

Since the treeview is in the parent page of RadWindow I suggest you check this help article. It should be something like this:

GetRadWindow().BrowserWindow.$('#TreeView').data(...)

All the best,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
General Discussions
Asked by
Eugene
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Eugene
Top achievements
Rank 1
Share this question
or