jQuery UI Widgets Forums Navigation Tree expand, ensure visible, select

This topic contains 2 replies, has 2 voices, and was last updated by  Liam 11 months, 3 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • expand, ensure visible, select #103715

    Liam
    Participant

    Hello, I’m trying to perform the following 3 actions with tree item :
    1) expand
    2) ensure visible
    3) select

    If item located in sub directory, it’s not scrolled to.

    Example :

    http://jsfiddle.net/mjytdnb6/

    Code :

    <div id='jqxTree'>
    	<ul>
    		<li>Home</li>
    		<li>Solutions
    			<ul>
    				<li>Education</li>
    				<li>Financial services</li>
    				<li>Government</li>
    				<li>Manufacturing</li>
    				<li>Solutions
    					<ul>
    						<li>Consumer photo and video</li>
    						<li>Mobile</li>
    						<li>Rich Internet applications</li>
    						<li>Technical communication</li>
    						<li>Training and eLearning</li>
    						<li id="myItem">Web conferencing</li>
    					</ul>
    				<li>Education</li>
    				<li>Financial services</li>
    				<li>Government</li>
    				<li>Manufacturing</li>
    				<li>All industries and solutions</li>
    			</ul>
    		</li>
    	</ul>
    </div>
    
    $('#jqxTree').jqxTree({
    	height: '150px',
    	width: '300px',
    	theme: 'energyblue'
    });
    var element = $("#myItem")[0];
    
    setTimeout(_ => {
    	$('#jqxTree').jqxTree('expandItem', element);
    	$('#jqxTree').jqxTree('ensureVisible', element);
    	$('#jqxTree').jqxTree('selectItem', element);
    }, 300);

    Thank you

    expand, ensure visible, select #103760

    Martin
    Participant

    Hello Liam,

    You can fix this by putting the ensureVisible action in a Timeout after calling the expandItem method,
    so the expanding is fully executed.

    I have updated your Example.

    Best Regards,
    Martin

    jQWidgets Team
    http://www.jqwidgets.com/

    expand, ensure visible, select #103766

    Liam
    Participant

    Thank you for solution.

    I think the “expandItem” should return a promise because of :
    1) 300ms is a pretty big time interval
    2) 300ms might not be enough for deep trees and “weak” browser

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.