jeudi 14 septembre 2017

Toggle primefaces Tree - Checkbox Selection by clicking just checkbox directly

Hi I'm using the component Tree - Selection with the variant Checkbox. Everything in the component is working fine but I need to put a button next to every child of my nodes to make something happen with the id of that node, the problem is that if I press the button that unchecks that node. This is my code:

<p:tree value="#{puntoscontrolController.rootDevices}" var="dev"
                                selectionMode="checkbox" selection="#{puntoscontrolController.selectedDevNodes}" style="border: none;"
>
                            <p:ajax event="select" listener="#{puntoscontrolController.selectUnidad(dev)}" update="growl"/>
                            <p:ajax event="unselect" listener="#{puntoscontrolController.unselectUnidad(dev)}" update="growl"/>
                            <p:treeNode type="ruta" icon="fa fa-list-ol">
                                <h:outputText value="#{dev.ruta}"/>
                            </p:treeNode>
                            <p:treeNode type="unidad" icon="fa fa-bus" >
                                <h:outputText value="#{dev.nombre}"/>
                                <button onclick="centrar(#{dev.idTraccar});">→</button>
                            </p:treeNode>
                        </p:tree>

And the result seems like this: Image of tree checkbox selection

The problem is that if i click anything inside the darker area of the node it unchecks that node so my question is if I can make the checkbox tree to make the selection event to happen just in the checkbox and not in the things inside the p:treenode?

I'm aware that this was possible in previous versions like 3.4.1 but I'm currently using the 6.0 version because I need some new features.




Aucun commentaire:

Enregistrer un commentaire