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

client-side .check() not working

3 Answers 76 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Stephen Arnold
Top achievements
Rank 1
Stephen Arnold asked on 07 Apr 2010, 06:26 PM

I have 2 treeviews and when I check something in one I need something to be checked in the other. The one that has the event is working and calling my checkNode(text) function. The checkNode function is executing everything correctly, except when it calls the node.check() nothing is happening. I made sure it is finding the node and has the right object, it is just not checking it. Code is below:


function

 

onNodeChecked(sender, args) {

 

 

var node = args.get_node();

 

 

if (node.get_checked()) {

 

 

if (node.get_text() == "Region") {

 

checkNode(

"Region");

 

checkNode(

"State");

 

}

}

}

 

function checkNode(text) {

 

 

var tree = $find("<%= ColumnTreeView.ClientID %>");

 

 

var node = tree.findNodeByText(text);

 

 

var nodetest = tree.findNodeByText("Region");

 

nodetest.check();

 

var nodes = tree.get_allNodes();

 

 

if (node != null) {

 

alert(

"checking something");

 

node.check();

}

}

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 08 Apr 2010, 03:04 PM

Hello Stephen,

Your code works fine in my end. Give a try with set_checked(true) method in order to check the item. Do you have any other settings which cancels the checkbox checking.

Could you provide complete code that you tried if this does not help?

-Shinu.

0
Stephen Arnold
Top achievements
Rank 1
answered on 08 Apr 2010, 03:29 PM
Here is the whole ascx. It is a user control not sure if that is part of the problem.

<%

@ Control Language="C#" AutoEventWireup="true" CodeBehind="CustomReportGeneratorParameters.ascx.cs"

 

 

Inherits="AttRADARWeb.Controls.CustomReportGeneratorParameters" %>

 

<%

@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

 

<

 

script type="text/javascript">

 

 

function onNodeChecked(sender, args) {

 

 

var node = args.get_node();

 

 

if (node.get_checked()) {

 

 

if (node.get_text() == "Region") {

 

checkNode(

"Region");

 

checkNode(

"State");

 

}

}

}

 

function checkNode(text) {

 

 

var tree = $find("<%= ColumnTreeView.ClientID %>");

 

 

var node = tree.findNodeByText(text);

 

 

var nodetest = tree.findNodeByText("Region");

 

nodetest.check();

 

var nodes = tree.get_allNodes();

 

 

if (node != null) {

 

node.check();

}

}

</

 

script>

 

<

 

div style="padding: 0 0 0 15px; width: 300px; float: left;">

 

 

<asp:Label ID="Label1" runat="server" Text="List Parameters" Font-Bold="True"></asp:Label>

 

 

<telerik:RadTreeView ID="ListAttributesTreeView" runat="server" CheckBoxes="true" CheckChildNodes="true" OnNodeDataBound="isAttributeCheckable"

 

 

BorderStyle="Ridge" Width="275px" Height="300px" TriStateCheckBoxes="true" OnClientNodeChecked="onNodeChecked">

 

 

<DataBindings>

 

 

<telerik:RadTreeNodeBinding Depth="0" />

 

 

</DataBindings>

 

 

</telerik:RadTreeView>

 

</

 

div>

 

<

 

div style="padding: 0 0 0 30px; width: 300px; float: left;">

 

 

<asp:Label ID="Label2" runat="server" Text="Campaign Parameters"

 

 

Font-Bold="True"></asp:Label>

 

 

<telerik:RadTreeView ID="CampaignAttributesTreeView" runat="server"

 

 

CheckBoxes="true" CheckChildNodes="true" OnNodeDataBound="isAttributeCheckable"

 

 

BorderStyle="Ridge" Width="275px" Height="300px" TriStateCheckBoxes="true"

 

 

onclientnodechecked="onNodeChecked">

 

 

<DataBindings>

 

 

<telerik:RadTreeNodeBinding Depth="0" />

 

 

</DataBindings>

 

 

</telerik:RadTreeView>

 

</

 

div>

 

<

 

div style="padding: 0 0 0 30px; width: 300px; float: left;">

 

 

<asp:Label ID="Label3" runat="server" Text="Column List" Font-Bold="True"></asp:Label>

 

 

<telerik:RadTreeView ID="ColumnTreeView" runat="server" CheckBoxes="true" BorderStyle="Ridge"

 

 

Width="275px" Height="300px" MultipleSelect="True"

 

 

ondatabound="ColumnTreeView_DataBound" EnableAjaxSkinRendering="False" >

 

 

</telerik:RadTreeView>

 

</

 

div>

 

0
Yana
Telerik team
answered on 09 Apr 2010, 08:46 AM
Hi Stephen Arnold,

I checked this code and still cannot reproduce the issue.  Please send us a runnable page demonstrating the issue. Thanks

All the best,
Yana
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
TreeView
Asked by
Stephen Arnold
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Stephen Arnold
Top achievements
Rank 1
Yana
Telerik team
Share this question
or