我有一个带InCell editing enabled的primeojis p:dataTable
,并且想要触发/激活新添加的行的RowEditor。
XHTML摘录
<p:commandButton id="btnAddEntry" value="Add new row" actionListener="#{myBean.addNewCar}" ... update="carTable growl" process="@this carTable ..."/>
<p:dataTable id="carTable" var="car" value="#{myBean.cars}" ... editable="true">
<p:column ...>
<p:cellEditor>
...
</p:cellEditor>
</p:column>
...
<p:column ...>
<p:rowEditor />
</p:column>
...
</p:dataTable>
到目前为止,这是 bean方法的内容:
public void addNewCar() {
Car newCar = new Car();
cars.add(newCar);
FacesContext facesContext = FacesContext.getCurrentInstance();
UIComponent uiTable = ComponentUtils.findComponent(facesContext.getViewRoot(), "carTable");
DataTable table = (DataTable) uiTable;
final AjaxBehavior behavior = new AjaxBehavior();
RowEditEvent rowEditEvent = new RowEditEvent(uiTable, behavior, table.getRowData());
rowEditEvent.setPhaseId(PhaseId.UPDATE_MODEL_VALUES);
table.broadcast(rowEditEvent);
}
我不知道
RowEditEvent(UIComponent component, Behavior behavior, Object object)
最佳答案
如果facelet中只有一个数据表,请尝试使用此表
oncomplete="jQuery('.ui-datatable-data tr').last().find('span.ui-icon-pencil').each(function(){jQuery(this).click()});
将此添加到命令按钮。这应该工作。
关于jsf-2 - 触发/激活来自bean的RowEditor,以启用质素启用单元内编辑功能p :dataTable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13821750/