ASPxClientTreeViewNode.GetChecked Method

Returns a value indicating whether the node is checked.

Declaration

GetChecked(): boolean

Returns

Type Description
boolean

true if the node is checked; otherwise, false.

Remarks

The ASPxTreeView allows end-users to check nodes. To determine whether the node is checked, use the GetChecked method on the client side. In order to check/uncheck a specific node on the client side, use the ASPxTreeView's ASPxClientTreeViewNode.SetChecked method.

To learn more, see the Check Box Support topic.

Examples

The code below lists checked nodes and shows them in a label on the client side.

<script type="text/javascript">
    function OnCheckedChanged(s, e) {
        label.SetText("Checked nodes:");
        ListCheckedNodes(s);
    }

    function ListCheckedNodes(parent){    
        for (var i=0; i < parent.GetNodeCount(); i++){
            if (parent.GetNode(i).GetChecked()){
               label.SetText(label.GetText() + " " + parent.GetNode(i).GetText());    
            }
            if (parent.GetNode(i).GetNodeCount() != 0){
               ListCheckedNodes(parent.GetNode(i));
            }
        }
    }
</script>
<dx:ASPxTreeView ID="ASPxTreeView1" runat="server" AllowCheckNodes="True" ClientInstanceName="treeview" DataSourceID="XmlDataSource1">
    <ClientSideEvents CheckedChanged="OnCheckedChanged" />
</dx:ASPxTreeView>
<br />
<dx:ASPxLabel ID="ASPxLabel1" runat="server" ClientInstanceName="label" Text="Checked nodes:">
</dx:ASPxLabel>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/App_Data/MenuTabbedMenu.xml" XPath="/mainmenu/item"></asp:XmlDataSource>
See Also