[Tree] Expand / Collapse using the entire label

UI Components for React
Post Reply
ShahinLotfi
Posts: 1
Joined: 16 Feb 2021, 15:07

16 Feb 2021, 18:43

Hi,

I'm using a basic Tree component with a custom nodeTemplate. I was wondering if there is a way to expand/collapse using the label, and not just the toggler. Any and all help is greatly appreciated!

Code: Select all

	const nodeTemplate = (node) => {
	        <div>
	        <!-- Use this button expand/collapse
	         <button>{node.label}</button>
        	</div>
        }
        
	<Tree
		value={menuData}
		className="dropdownTree"
		nodeTemplate={nodeTemplate}
    	/>
Also, thank you for an awesome component library!

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

06 May 2021, 23:23

Hi,

I made some changes related to nodeTemplate. You can use it with options.onTogglerClick event on 6.3.2+. Details; https://github.com/primefaces/primereact/issues/2019

Code: Select all

const nodeTemplate = (node, options) => {
	        <div className={options.className}>
	        	<!-- Use this button expand/collapse
	                <button type="button" onClick={options.onTogglerClick}>{node.label}</button>
        	</div>
        }
Best Regards,

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 12 guests