I know there are many solutions for my problem, but no one is fine for me. Here is my situation: I want to select a node by node id programmatically, In the .ascx file a function has been defined:
function InitializeNodeState(nodeID)
{
$('#<%=ClientID %>').jstree("select_node", "#"+nodeID);
};
and in the vb file another function has been defined to call above function:
Public Sub SelectedRooteNodeToInitializeState(node As TreeNode)
Dim rooteNode As TreeNode = Me.Nodes(0)
If rooteNode.id = node.id Then
Page.ClientScript.RegisterStartupScript(Me.GetType(), "script","InitializeNodeState(" + rooteNode.id + ");", True)
End If
End Sub
My questions are:
The value of the property 'InitializeNodeState' is null or undefined, not a Function object.
$('#<%=ClientID %>').jstree("select_node", "#"+nodeID);
seems does not work. Please educate me, thanks.
Here is additional information about my problem:
the value of state parameter for all nodes in jstree is null until user click the jstree, so I want to select a node by its id to initialize node state before user click the jstree.
Additionally, you might need to change this:
Page.ClientScript.RegisterStartupScript(Me.GetType(), "script","InitializeNodeState(" + rooteNode.id + ");", True)
to this:
Page.ClientScript.RegisterStartupScript(Me.GetType(), "script","InitializeNodeState('" + rooteNode.id + "');", True)
set runat server for your node
for instance
<tr runat="server" id="myNode"></tr>
$('#<%=yourElement.ClientID %>').jstree("select_node", "#"+nodeID);
Public Sub SelectedRooteNodeToInitializeState(node As TreeNode)
Dim rooteNode As TreeNode = Me.Nodes(0)
If rooteNode.ClientID = myNode.ClientID Then
Page.ClientScript.RegisterStartupScript(Me.GetType(), "script","InitializeNodeState(" + myNode.ClientID + ");", True)
End If
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.