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

RADTreeView's nodes getting lost on initial postback

7 Answers 210 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Jomar
Top achievements
Rank 1
Jomar asked on 13 Jul 2010, 06:12 PM
Does anyone know why this is happening when you click or expand the first node of a RADTreeView Control on initial load of the page but is working fine on succeeding postbacks? Thanks

7 Answers, 1 is accepted

Sort by
0
Nikolay Tsenkov
Telerik team
answered on 15 Jul 2010, 02:08 PM
Hi Jomar,

Could you, please, specify in a bit more detail, what exactly is the problem that you experience?
Also, could you provide some code that reproduces the problem?
Thanks!

I hope that we will resolve your problem soon!


Regards,
Nikolay Tsenkov
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
0
Jomar
Top achievements
Rank 1
answered on 15 Jul 2010, 02:40 PM
Hi,

This is a RadTreeView control inside a WSS 3.0 WebPart. I have built it inside a RadAjaxPanel which is inside a RadPane of a RadSplitter control which is inside the main(final) RadAjaxPanel.


I am creating and populating the tree under CreateChildControls method

        private void InitTree()
        {
            try
            {
                // Init the properties of the loading panel control
                _lpnTree.ID = "_lpnTree";
                _lpnTree.InitialDelayTime = 0;
                _lpnTree.IsSticky = false;
                _lpnTree.HorizontalAlign = HorizontalAlign.Center;

                // Set the path for itschild image control...
                Image loadingImage = new Image();
                loadingImage.ImageUrl = @"/RadControls/Ajax/Skins/Default/loading.gif";

                _lpnTree.Controls.Add(loadingImage);

                // Init the properties of the parent ajax panel
                _pnlTree.ID = "_pnlTree";
                _pnlTree.Width = new Unit(100, UnitType.Percentage);
                _pnlTree.Height = new Unit(400, UnitType.Pixel);
                _pnlTree.EnableAJAX = true;
                _pnlTree.EnableViewState = true;
                _pnlTree.LoadingPanelID = _lpnTree.ID;

                // add the loading panel
                _pnlTree.Controls.Add(_lpnTree);

                // Init the tree properties
                _tvwDocuments.ID = "_tvwDocuments";
                _tvwDocuments.EnableViewState = true;

                // Add Javascript Client Event handlers
                _tvwDocuments.OnClientNodeChecked = "TreeAfterCheckHandler";
                _tvwDocuments.OnClientMouseOver = "AfterClientHighlightHandler";
                _tvwDocuments.OnClientNodeClicked = "AfterClientClickHandler";

                // Add the server event handlers
                _tvwDocuments.NodeExpand += new Telerik.Web.UI.RadTreeViewEventHandler(_tvwDocuments_NodeExpand);
                _tvwDocuments.NodeCheck += new Telerik.Web.UI.RadTreeViewEventHandler(_tvwDocuments_NodeCheck);

                // Set the server event to handle 
                _pnlTree.AjaxRequest += new Telerik.Web.UI.RadAjaxPanel.AjaxRequestDelegate(_pnlTree_AjaxRequest);
            }
            catch (Exception ex)
            {
                .....
            }
        }


        protected override void CreateChildControls()
        {
            try
            {
                InitTree();

                if (!Page.IsPostBack)
                {

                    BuildTree();
                }
                
              // This is kinda fix to the problem but again you will have to click or expand twice the node before it fires an ajaxRequest                         // method inside a javascript.
               if (_tvwDocuments.IsEmpty)
                {
                    BuildTree();
                }
        }

  On succeeding postbacks, _tvwDocuments will not be empty anymore.





0
Jomar
Top achievements
Rank 1
answered on 15 Jul 2010, 02:48 PM
Whoa looks like there is a rendering problem in this forum. ^_^.

My previous message was garbled.
0
Jomar
Top achievements
Rank 1
answered on 15 Jul 2010, 03:03 PM
Ooops didn't show up again.
0
Nikolay Tsenkov
Telerik team
answered on 20 Jul 2010, 10:12 AM
Hi Jomar,

As much as I can see from the provided code, the problem is that you add a TreeView as control in the Controls collection of another TreeView. This isn't something that is explicitly supported and there isn't that much need (I personally don't see one at all) to perform such an action.
If there are nodes that you should transfer from one tree to another, then you can just do so, with adding the entire tree.

The best way to go about such a problem, I think, would be for you to give me a set of requirements and I will help you achieving and implementing them the right way using our controls.

If you still insist on keeping this same implementation, a fix for your current problem would be to move this InitTree method to execute on Page_Init time on do this on every post back. Still I wouldn't recommend you this option.

Hope this is helpful for you!


Regards,
Nikolay Tsenkov
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
0
Jomar
Top achievements
Rank 1
answered on 20 Jul 2010, 02:08 PM
Hi Nikolay,

No it is just one RadTreeView  (_tvwDocuments) control inside a RadAjaxPanel (_pnlTree) with RadLoadingPanel (_lpnTree).

Moving the Init_Tree to OnInit didn't help.

This is how I constructed the OnInit

        protected override void OnInit(EventArgs e)
        {
            try
            {
                base.OnInit(e);

                Page.ClientScript.RegisterStartupScript(typeof(DocumentManagerWP), this.ID, "_spOriginalFormAction = document.forms[0].action;_spSuppressFormOnSubmitWrapper=true;", true);
                if (this.Page.Form != null)
                {
                    string formOnSubmitAtt = this.Page.Form.Attributes["onsubmit"];
                    if (!string.IsNullOrEmpty(formOnSubmitAtt) && formOnSubmitAtt == "return _spFormOnSubmitWrapper();")
                    {
                        this.Page.Form.Attributes["onsubmit"] = "_spFormOnSubmitWrapper();";
                    }
                }

                ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);
                if (scriptManager == null)
                {
                    scriptManager = new Telerik.Web.UI.RadScriptManager();
                    this.Page.Form.Controls.AddAt(0, scriptManager);

                }

        }

The RadTreeView is just failing initially (1st node click or node expand). But when you do a postback first like changing the DataSource of the RadTreeView thru a dropdown before clicking or expanding the node it will work fine. Any other thoughts? Thanks
0
Nikolay Tsenkov
Telerik team
answered on 23 Jul 2010, 02:40 PM
Hello Jomar,

Please open a support ticket and send me a simple project reproducing this strange behavior.

Hope that we will resolve it soon!


Regards,
Nikolay Tsenkov
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
Jomar
Top achievements
Rank 1
Answers by
Nikolay Tsenkov
Telerik team
Jomar
Top achievements
Rank 1
Share this question
or