简体   繁体   English

通过Javascript设置Telerik RadTreeView属性,例如OnClientNodeExpanded

[英]Setting Telerik RadTreeView attributes such as OnClientNodeExpanded via Javascript

I have a RadTreeView which that can eb referenced by the variable: TV 我有一个RadTreeView,它可以被以下变量引用: TV

I did not know if i could just do jQuery to do $(TV).attr("OnClientNodeExpanded","newvalue") because there might be a server side link that i may be unaware of. 我不知道如果我能这样写:jQuery做$(TV).attr(“OnClientNodeExpanded”,“NEWVALUE”),因为有可能是一个服务器端的链接,我可能不知道的。

When I defined my RadTreeView in the markup, it has 2 attributes: OnClientNodeExpanded and OnClientNodeClicked which are set to some javascript functions. 当我在标记中定义RadTreeView时,它具有2个属性:OnClientNodeExpanded和OnClientNodeClicked,这些属性设置为某些javascript函数。

My question is as follows: 我的问题如下:

Is there a way to change where both OnClientNodeExpanded and OnClientNodeClicked point by some reference like: *TV.set_ClientNodeExpanded("NEW_FUNCTION");* 有没有一种方法可以通过一些引用来更改OnClientNodeExpanded和OnClientNodeClicked的位置,例如:* TV.set_ClientNodeExpanded(“ NEW_FUNCTION”); *

I want to depending on what is clicked have the RadTreeView populate different material. 我想根据单击的内容将RadTreeView填充为不同的材料。

Edit to help clarify my goal: The asp.net control has those attributes. 编辑以帮助阐明我的目标: asp.net控件具有这些属性。 Which means that the functions, are actually loadNode and clickedNode. 这意味着这些功能实际上是loadNode和clickedNode。 What i was wanting to do was to change the reference of those attributes listed above to point to a different function. 我想要做的是更改上面列出的那些属性的引用,以指向不同的功能。 I wasnt sure i wanted to have an intermediate "judging" function to determine what functions were to be called, but instead a way to override the current declaration as to what fires when the RadTreeView Event Occurs. 我不确定我是否希望有一个中间的“判断”函数来确定要调用的函数,而是一种重写当前声明的方法,以了解当RadTreeView事件发生时将触发的事件。 Does that clarify? 这澄清了吗?

In your javascript OnClientNodeClicked function, you can check which item was clicked and then call the function you want. 在您的javascript OnClientNodeClicked函数中,您可以检查单击了哪个项目,然后调用所需的函数。

function OnClientNodeClicked(sender, eventArgs) {
    var node = eventArgs.get_node();

    if(yourConditionHere){
        callFunctionA();
    }
    else{
        callFunctionB();
    }
}    

Did I understand you correctly? 我对你的理解正确吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM