Ticket Q334557
Visible to All Users

ASPxTreelist - How to get selected node values

created 14 years ago

Hello,
I've been searching for whole day how we simple can get the value we've checked. If we check or uncheck the "Checkbox" of the treelist, the -SelectionChanged="onClick"- is called on the "Client" & "Server" side. But there's no way to get the "ID" of the checkbox you've just checked or unchecked! If they check a node, an item must be created in the DB (i need the ID for doing that); If they uncheck a node, the item must be deleted in the DB. But how do we get the value? While watching in the debugger in the javascript, I didn't find how to get the ID. Only the "selectionDiff" contains the ID I need, but there no way to get it…
        function onClick(s, e) {
            //af7a8728-467f-e011-8de3-005056bf5b64
            //var id = typeof (s.selectionDiff);
            document.getElementById("getNodeKey").value = "Selection Changed";
        }
If I watch on the "Server"-side, I don't have an option of getting the actual checked property :
        protected void ASPxTreeList1_SelectionChanged(object sender, EventArgs e)
        {
                //HERE we only can loop trough all the selected and that NOT good!
         }
The focused rows functions aren't called yet…
My ASPxTreeList :
        <dx:ASPxTreeList ID="ASPxTreeList1" runat="server" AutoGenerateColumns="False"
            CssFilePath="~/App_Themes/Office2010Silver/{0}/styles.css"
            CssPostfix="Office2010Silver" ondatabound="ASPxTreeList1_DataBound"
            oncommandcolumnbuttoninitialize="ASPxTreeList1_CommandColumnButtonInitialize"
            onfocusednodechanged="ASPxTreeList1_FocusedNodeChanged"
            onhtmlrowprepared="ASPxTreeList1_HtmlRowPrepared"
            onselectionchanged="ASPxTreeList1_SelectionChanged"
            oncustomcallback="ASPxTreeList1_CustomCallback" >
<Settings SuppressOuterGridLines="True"></Settings>
<SettingsBehavior ProcessFocusedNodeChangedOnServer="True"
                ProcessSelectionChangedOnServer="True"></SettingsBehavior>
            <Columns>
                <dx:TreeListDataColumn FieldName="Name" VisibleIndex="0" />
                <dx:TreeListCommandColumn>
                    <EditButton Visible="True" />
<EditButton Visible="True"></EditButton>
                </dx:TreeListCommandColumn>
            </Columns>
            <Settings SuppressOuterGridLines="True" />
            <SettingsBehavior ProcessFocusedNodeChangedOnServer="true" ProcessSelectionChangedOnServer="true" />
            <Images SpriteCssFilePath="~/App_Themes/Office2010Silver/{0}/sprite.css">
                <LoadingPanel Url="~/App_Themes/Office2010Silver/TreeList/Loading.gif">
                </LoadingPanel>
            </Images>
            <Styles CssFilePath="~/App_Themes/Office2010Silver/{0}/styles.css"
                CssPostfix="Office2010Silver">
                <LoadingPanel ImageSpacing="5px">
                </LoadingPanel>
            </Styles>
            <StylesEditors ButtonEditCellSpacing="0">
            </StylesEditors>
            <ClientSideEvents SelectionChanged="onClick" />
        </dx:ASPxTreeList>

I bind the data on the "Page_Load", where I put "ID" as the actual datakey :
                ASPxTreeList1.KeyFieldName = "ID";
                ASPxTreeList1.ParentFieldName = "TypeID";
Each time the "DB" is build, we set which fields needs to be selected and such… So I can't see which were checked or unchecked. That's why I realy need the ID to do the needed work!
As extra addition, I need to be able to update only the "Selected" Items => Nothing else can be updated… I figured out how to set the "Edit"-button on the "CHECKED" fields and so, but how do I define my own custom "Update"-Fields, based on other data from another table => When the node is checked it means that there is another table that is connected to that "ID". It's that data we need to update and there are some CUSTOM COMBOBOXES I need to build, but how do I achieve this? Is the "ASPxTreeList" control strong enough to support this? I really need a fast answer on this!
Kind Regards,
Frederic

Answers approved by DevExpress Support

created 14 years ago (modified 11 years ago)

Hello Frederic,
Thank you for contacting us. Please take a look at the server-side ASPxTreeList.GetSelectedNodes, client-side ASPxClientTreeList.GetSelectedNodeValues and ASPxClientTreeList.GetVisibleSelectedNodeKeys methods. Do they suit your requirements ?
Please note that our Support Center concept does not allow posting multiple problems within a thread as this makes it difficult to properly track such items.
I have created a new issue for your second question.
ASPxTreelist - How to update controls on a page after ASPxTreelist has been updated
Regards,
Jenny

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.