The requested page is not available for the requested platform. You are viewing the content for Default platform.

ASPxClientTreeList.FocusedNodeChanged Event

Fires in response to changing node focus.

Declaration

FocusedNodeChanged: ASPxClientEvent<ASPxClientProcessingModeEventHandler<ASPxClientTreeList>>

Event Data

The FocusedNodeChanged event handler receives an argument of the ASPxClientProcessingModeEventArgs type. The following properties provide information specific to this event.

Property Description
processOnServer Gets or sets a value that specifies whether the event should be finally processed on the server side.

Remarks

The FocusedNodeChanged event is raised when an end-user moves focus from one node to another. The focused node's key value is returned by the ASPxClientTreeList.GetFocusedNodeKey method.

The event parameter's processOnServer property enables you to specify where the current user action should be processed - either on the client side or on the server side. If this property is set to false in a client event's handler, the event is completely handled on the client side without a postback to the server. Setting the processOnServer property to true indicates that the final processing of the event should be performed on the server side. During such a round trip the ASPxTreeList.FocusedNodeChanged server-side event is fired, which if handled, allows any desired server-side action to be performed.

Note

If the TreeListSettingsBehavior.ProcessFocusedNodeChangedOnServer property is set to true, setting the event parameter's processOnServer property has no effect. In this instance, the ASPxTreeList.FocusedNodeChanged server-side event is always fired after the FocusedNodeChanged client event.

The focused node feature is enabled if the TreeListSettingsBehavior.AllowFocusedNode property is set to true.

Examples

This example demonstrates how to use the GetFocusedNodeKey method to expand and collapse tree nodes based on the state of a node (collapsed or expanded). You can get the node state by calling the GetNodeState(nodeKey) method in the FocusedNodeChanged event.

Demo limitation: if you close the topmost parent node and do not have other nodes except that one, you will have to expand this node by clicking the Expand Button.

<script>
    function OnFocusedNodeChange(s, e) {
        var nodeKey = s.GetFocusedNodeKey();
        var nodeState = s.GetNodeState(nodeKey);

        if (nodeState === "Collapsed")
            s.ExpandNode(nodeKey);
        else if (nodeState === "Expanded")
            s.CollapseNode(nodeKey);
    };
</script>
<dx:ASPxTreeList ID="TreeList"
    runat="server"
    AutoGenerateColumns="False" 
    DataSourceID="ProductsDataSource" 
    KeyFieldName="EmployeeID" 
    ParentFieldName="ReportsTo"
    Width="50%">
    <Columns>
        <dx:TreeListTextColumn FieldName="EmployeeID" VisibleIndex="0" ReadOnly="true"></dx:TreeListTextColumn>
        <dx:TreeListTextColumn FieldName="LastName" VisibleIndex="1"></dx:TreeListTextColumn>
        <dx:TreeListTextColumn FieldName="FirstName" VisibleIndex="2"></dx:TreeListTextColumn>
    </Columns>
    <SettingsBehavior AllowFocusedNode="true" FocusNodeOnLoad="false" />
    <ClientSideEvents FocusedNodeChanged="OnFocusedNodeChange" />
</dx:ASPxTreeList>
<br />

<asp:AccessDataSource ID="ProductsDataSource" runat="server"
    DataFile="~/App_Data/nwind.mdb"
    SelectCommand="SELECT [EmployeeID], [LastName], [FirstName], [ReportsTo] FROM [Employees]">
</asp:AccessDataSource>
See Also