Primefaces 在对话框中的datatable筛选器中避免焦点

Primefaces 在对话框中的datatable筛选器中避免焦点,primefaces,focus,Primefaces,Focus,我有一个带有datatable的弹出对话框,我想在filter inputText字段中没有焦点。我想把注意力集中在这张桌子下面的按钮上。 我试过这个: <p:focus id="focus" for="buttonFocus" context="dialog"/> <p:dialog id="dialog" header="Выбор организации" widgetVar="vDialog" modal="true" resizable="false">

我有一个带有datatable的弹出对话框,我想在filter inputText字段中没有焦点。我想把注意力集中在这张桌子下面的按钮上。 我试过这个:

<p:focus id="focus" for="buttonFocus" context="dialog"/>
<p:dialog id="dialog" header="Выбор организации" widgetVar="vDialog" modal="true" resizable="false">  
    <p:dataTable 
    dblClickSelect="true"
    id="table"               
                 var="record"
                 value="#{myBean.tableList}"
                 rowKey="#{record.waId}"
                 filteredValue="#{myBean.filteredList}" 
                 lazy="true"                                                             
                 >                                                                      
                <p:column headerText="Name" filterBy="#{recordp.name}" sortBy="#{recordp.name}">                                    
                         #{record.name}
                </p:column>                                                                                                 
     </p:dataTable>  
        <p:commandButton id="buttonFocus" actionListener="#{myBean.fill}"/>     
</p:dialog>

#{record.name}
这没用。
那么,在这种情况下如何设置聚焦按钮呢?

我找到了一些建议

因此,首先对我起作用的是:

       <script type="text/javascript">

       PrimeFaces.widget.Dialog.prototype.applyFocus = function() {
          var firstInput = this.jq.find('#buttonFocus');
              firstInput.focus();
       }
       </script>

PrimeFaces.widget.Dialog.prototype.applyFocus=函数(){
var firstInput=this.jq.find(“#buttonFocus”);
focus();
}
这种方法不需要p:focus。同时也不要忘记在表单中添加prependId=“false”,否则id会改变

第二个仅适用于输入元素(不适用于按钮):


PrimeFaces.widget.Dialog.prototype.applyFocus=函数(){
}
这里需要p:focus元素,但正如我所说的,这只适用于输入

第三个解决方案如果您有正确版本的primefaces(未测试),您可以查看此解决方案

       <script type="text/javascript">

       PrimeFaces.widget.Dialog.prototype.applyFocus = function() {

       }
       </script>