问题描述
我有一个弹出对话框的数据表,我想在过滤器inputText字段没有焦点。我想把焦点放在这张表下面的按钮上。
我试过这个:
< p:focus id =focusfor =buttonFocuscontext =对话/>
< p:dataTable
dblClickSelect =true
id =table
var =record
value =#{myBean.tableList}
rowKey =#{record.waId}
filteredValue =#{myBean.filteredList}
lazy =true
>
< p:column headerText =NamefilterBy =#{recordp.name}sortBy =#{recordp.name}>
#{record.name}
< / p:列>
< / p:dataTable>
< p:commandButton id =buttonFocusactionListener =#{myBean.fill}/>
< / p:dialog>
没有帮助。
那么,如何在这种情况下设置按钮的焦点?
所以第一个一个,对我来说是这样的:
< script type =text / javascript>
PrimeFaces.widget.Dialog.prototype.applyFocus = function(){
var firstInput = this.jq.find('#buttonFocus');
firstInput.focus();
}
< / script>
这个方法不需要p:focus。另外,不要忘记添加prependId =false形式,否则id会改变。
第二个 (不带按钮):
< script type =text / javascript>
PrimeFaces.widget.Dialog.prototype.applyFocus = function(){
}
< / script>
这里你需要p:focus元素,但是就像我说过的那样只能用于输入。 >
和第三解决方案,您可以在,如果你有正确版本的primefaces(未测试)
I have a popup dialog with datatable and I want to have no focus in filter inputText fields. I want to have focus on button under this table.I tried this:
<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>
it doesn't help.So, how to set focus on button in such situation?
I found several suggestions.
So first one, which worked for me is:
<script type="text/javascript">
PrimeFaces.widget.Dialog.prototype.applyFocus = function() {
var firstInput = this.jq.find('#buttonFocus');
firstInput.focus();
}
</script>
You don't need p:focus for this method. And also don't forget add prependId="false" to form, because otherwise id will change.
Second which worked with input elements only (not with button):
<script type="text/javascript">
PrimeFaces.widget.Dialog.prototype.applyFocus = function() {
}
</script>
Here you need p:focus element, but like I said this works with inputs only.
And third solution you can look in this blog , if you have right versions of primefaces (not tested)
这篇关于避免在对话框中关注数据过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!