1. #1
    Ext JS Premium Member
    Join Date
    Feb 2008
    Posts
    51
    Vote Rating
    0
    noamway is on a distinguished road

      0  

    Question Unanswered: Move a search function from version 3 to version 4

    Unanswered: Move a search function from version 3 to version 4


    Hi,

    I try without any success to migrate this function from version 3 to 4:
    Code:
    //********************** Search For  - FOLDERS - *************************************
    var hiddenPkgs  = [];
    var markCount	= [];
    
    // filter the kb tree for hits
    function filterTree(e){
    	var text = e.target.value;
    	Ext.each(hiddenPkgs, function(n){
    		n.ui.show();
    	});
    	
    	markCount  = [];	
    	hiddenPkgs = [];
    	
    	if( text.trim().length > 0 ){
    		Ext.getCmp('treeFolderList').expandAll();
    		
    		var re = new RegExp( Ext.escapeRe(text), 'i');
    		Ext.getCmp('treeFolderList').root.cascade( function( n ){
    			if( re.test(n.text) )
    				markToRoot( n, Ext.getCmp('treeFolderList').root );
    		});
    		
    		// hide empty packages that weren't filtered		
    		Ext.getCmp('treeFolderList').root.cascade(function(n){
    			if( ( !markCount[n.id] || markCount[n.id] == 0 ) && n != Ext.getCmp('treeFolderList').root ){
    				n.ui.hide();
    				hiddenPkgs.push(n);
    			}
    		});
    	}
    }
    
    function markToRoot( n, root ){
    	
    	if( markCount[n.id] )
    		return;
    		
    	markCount[n.id] = 1;
    	
    	if( n.parentNode != null )
    		markToRoot( n.parentNode, root );
    }
    //********************** Search For  - FOLDERS - *************************************
    I really like to know what is the easy way to do that or maybe someone can make us an example here. Now we're getting error here: root.cascade and we don't find how to do that in version 4.

    Thanks for the help,
    Noam

  2. #2
    Sencha - Community Support Team friend's Avatar
    Join Date
    Apr 2011
    Posts
    895
    Vote Rating
    27
    Answers
    106
    friend has a spectacular aura about friend has a spectacular aura about

      0  

    Default


    Try this instead:

    Code:
    Ext.getCmp('treeFolderList').getRoot().cascade( function( n ){
      if( re.test(n.text) )
        markToRoot( n, Ext.getCmp('treeFolderList').getRoot() );
    });
    I'd also evaluate the return object from Ext.getCmp() to ensure you're actually getting a reference to the Tree.

Thread Participants: 1

Tags for this Thread