I am using PrimeFaces 5.1
in my application,I used selectOneMenu
inside of dataTable
, When I press on add more button to need to focus selectOneMenu
button.
Sample Code
JavaScript
function focusMenu(id)
{
var focusId="#{p:component('mainTable')}"+":"+id;
PrimeFaces.focus(final);
}
xhtml
<div style="padding-left:4px;height:
expression(this.scrollHeight > 399? '400px' : 'auto');max-height:400px;overflow-x:auto;overflow-y:auto;">
<p:dataTable id="mainTable" value=#{main.UserDataTable} .....>
<p:column headerText="Drop Down">
<p:selectOneMenu id="dropdDownId"...>
.....
</p:selectOneMenu>
</p:column>
<p:column headerText="Operation">
<p:commandButton value="Add More Row" action="{user.addMoreRowAction}"
update="mainTable"/>
</p:column>
</p:dataTable>
</div>
Java
public String addMoreRowAction()
{
RequestContext.getCurrentInstance().execute("focusMenu('"+ rowIndex + ":dropdDownId"')");
return null;
}
Here the above code is work fine to focus the last added selectOneMenu
as what I expected, but the browser scroll bar is not move down based on focusing the recently added selectOneMenu
component.
Please help me to solve the issue.