0

I'm trying to accept an editRow event on a Primefaces TreeTable by pressing the ENTER key. But at the time of doing so, <p:commandButton/> catches the event.

I tried in an <h:outputScript/> jQuery:

        $('tmt-library-tree').keypress(function(event) {
            if(event.which == '13') {
                event.preventDefault();
            } 
        });

But it affects the entire TreeTable. I also tried selectors in the form of:

$("#screens\\:form\\:libraryGroupTreeTable\\:addGlobal").keypress(function(event) {
            if(event.which == '13') {
                event.preventDefault();
            } 
        });

Taken from the Inspect window in Chrome Developer Tools and making sure it exists.

This is the Primefaces TreeTable

<p:treeTable id="libraryGroupTreeTable" styleClass="library-tree" 
                 var="dummy" nodeVar="hltsOrHltsfOrLg" value="#{libraryTree}" emptyMessage=""
                 selectionMode="single" editable="#{editable}" scrollable="true">

and added an <p:ajax> to handle rowEdit

<p:ajax event="rowEdit" listener="#{libraryTree.onRowEdit}" onstart="vres.onAjax(cfg, '#{libraryTree.gid}');" update="libraryGroupTreeTable"/>

Finally, here's my <p:outputPanel>

<p:outputPanel id="namePanel" style="display: inline-flex;">
            <span class="tree-node-icons #{hltsOrHltsfOrLg.css}"/>
            <div style="margin-top: 3px;">
              <p:cellEditor>
                <f:facet name="input"><p:inputText value="#{hltsOrHltsfOrLg.name}"/></f:facet>
                <f:facet name="output"><h:outputText value="#{hltsOrHltsfOrLg.name}"/></f:facet>
              </p:cellEditor>
            </div>
 </p:outputPanel>

I need the ENTER Key to do what the <p: ajax/> tag is doing at the moment of editing the cell.

Thanks in advance!

EdUrbinaDev
  • 3
  • 1
  • 6
  • Possible duplicate of [How to stop event propagation with inline onclick attribute?](https://stackoverflow.com/questions/387736/how-to-stop-event-propagation-with-inline-onclick-attribute) – Selaron Apr 17 '19 at 09:33
  • I need to do the actions from ``` ```. But in the key ENTER event. – EdUrbinaDev Apr 17 '19 at 14:55

0 Answers0