Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable primefaces tree with checkbox selection mode

Tags:

primefaces

I have a requirement to disable a primeface tree (checkbox selection mode) for some occasions.User should be able to see selected as well as un-selected checboxes, but they need to be disabled in this occasion. Does anybody know how to do it? Iam using PF 4

like image 258
bluelabel Avatar asked Mar 11 '14 03:03

bluelabel


2 Answers

You can set for node userNode.setSelectable(false) and in jsf treetable add

showUnselectableCheckbox="true"
like image 108
Vladislav Karpenko Avatar answered Oct 06 '22 12:10

Vladislav Karpenko


I found a solution for this. But is not elegant, this can be done with css, We can add a conditional css to the tree and make it unclickable.

    .not-clickable {
    cursor: not-allowed;
    pointer-events: none;
}

Used above css style in the tree with a condition,

<p:tree id="tree" styleClass="#{not backingBean.editable?'not-clickable':''}" cache="false" value="#{backingBean.treeRoot}" var="node" selectionMode="checkbox" selection="#{backingBean.selectedValuesNodes}">
like image 30
bluelabel Avatar answered Oct 06 '22 10:10

bluelabel