Tree with selectionMode single: toggle selection on click?

UI Components for JSF
Post Reply
frans
Posts: 2
Joined: 05 Oct 2016, 18:41

24 May 2018, 18:23

Hi,

I'm running PF 6.2.3 and I have a tree with selectionMode="single".
I can select an item with a simple click but the only way I found to deselect it is to do Ctrl-click.
Is there a way to change that? Ideally, a click on a tree node would toggle its selection state.

Thanks!

François

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

24 May 2018, 21:53

The source is open: https://github.com/primefaces/primefaces/blob/master/

The Tree js source is here: https://github.com/primefaces/primeface ... ee/tree.js

The code that handles the nodeClick is here: https://github.com/primefaces/primeface ... ee.js#L279

The line that checks for a metakey and only unselect then is on: https://github.com/primefaces/primeface ... ee.js#L297

That variable is set on https://github.com/primefaces/primeface ... ee.js#L290

Selection with a metakey also works as can be deduced from the code, so giving it a fixed value will solve your problem.

If you create a stackoverflow question, I'm more than happy to create an answer for you there (and then also here ;-))

frans
Posts: 2
Joined: 05 Oct 2016, 18:41

30 May 2018, 17:38

Ok, thanks for your answer, kukeltje.
I was hoping there was a way to customize that without having to change the source code.

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

30 May 2018, 21:13

Not everything is possible without changes to code. Your'e the first one that requested this. You can ofcourse make a patch the makes it configurable in the xhtml on the component and file a pull request. Then it might get incorporated in the next release.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 32 guests