The official release of Ext.NET Mobile is now available. Ext.NET Mobile is an ASP.NET component framework for building Phone and Tablet specific mobile web applications. Read More

Select TreeNode after Append

  1. #1

    Select TreeNode after Append

    Hello,
    I am trying to select a tree node after appending it from a controller. I append the node from the controller as follows...

    var oChildNode = oControl.ToExtNetNode ( );
    
    Ext.Net.TreePanel oTreePanel
    	= Ext.Net.X.GetCmp<Ext.Net.TreePanel>
    		( nsMyIdentify.IdMapEnum.DesignerTreePanelForProjectExplorer.ToString ( ) );
    
    var oNode = oTreePanel.GetNodeById ( containerId );
    
    oNode.AppendChild ( oChildNode );
    
    oNode.Expand ( true );
    I have tried to select the node both from the controller and from the client, but have not been able to do either.

    In an attempt to select the node from the controller, i do the following...

    var oSelectionModel
    	= oTreePanel.GetSelectionModel ( );
    
    if ( oSelectionModel != null )
    {
    	oSelectionModel.Select ( oChildNode.NodeID );
    }	
    else 
    {
    	var oTreeSelectionModel
    		= new Ext.Net.TreeSelectionModel
    		{
    			Mode = Ext.Net.SelectionMode.Single,
    
    			SelectedRecordID = oChildNode.NodeID 
    		};
    
    	oTreePanel.SelectionModel.Add
    		( oTreeSelectionModel );
    }
    the TreePanel.GetSelectionModel() is always returning null and the remainder of the code does not select the newly appended node.

    When i try from javascript, i add a listener for the "ItemAppend" function of the treepanel. The javascript function looks like this...

    this.OnItemAppendDoSelectNode = function (sender, node, index, options)
    {
    
            this.getSelectionModel().select(node.id);
    
            OR
    
            this.getSelectionModel().select(index);
    }
    I get the error message that the "select" is "undefined"

    I have spent all day trying to get this working but have had not luck.
  2. #2
    Client side events in JS are added like this. Your syntax isnt correct. Below is an example for a button. Please be sure to review the docs at sencha to verify your button is valid http://www.sencha.com/docs
    /Z

    Button1.on(
        "click",
        function (button, e) {
            alert(‘The button is clicked’);
        }
    );
  3. #3
    the event is firing fine...the issue is that
     this.getSelectionModel()
    does not have a "select" method as shown in examples. How do you actually select the newly appended node?
  4. #4
    the reason it doesnt work is that you are trying to work in code behind or server side code.

    either one of these should work in javascript

    /Z

    grid.getSelectionModel().select(index);
    store.load({
        callback: function (records, operation, success) {        
            var rowIndex = this.find('id', record.getId());  //where 'id': the id field of your model, record.getId() is the method automatically created by Extjs. You can replace 'id' with your unique field.. And 'this' is your store.
            grid.getView().select(rowIndex);
        }
    })
  5. #5
    No, I am not working in code behind and i am using a treepanel and not a grid...that is a javascript function in a standalone javascript file that i have listed above and again below...

    this.OnItemAppendDoSelectNode = function (sender, node, index, options)
    {
    
            this.getSelectionModel().select(node.id);
    
            OR
    
            this.getSelectionModel().select(index);
    }

Similar Threads

  1. [CLOSED] Treenode link and select
    By xeo4.it in forum 1.x Premium Help
    Replies: 6
    Last Post: Jan 17, 2011, 9:33 AM
  2. [CLOSED] [1.0] How to select a treenode in codebehind?
    By klaus.schwarz in forum 1.x Premium Help
    Replies: 2
    Last Post: Nov 01, 2010, 4:00 PM
  3. Replies: 0
    Last Post: Dec 10, 2009, 12:14 PM
  4. How to select TreeNode with Up/Down keys?
    By dbassett74 in forum 1.x Help
    Replies: 0
    Last Post: May 26, 2009, 8:23 PM
  5. [CLOSED] Select TreeNode Programatically
    By Ben in forum 1.x Premium Help
    Replies: 1
    Last Post: Feb 04, 2009, 10:45 AM

Tags for this Thread

Posting Permissions