p:dataTable clearFilters() 在创建新行后将其删除,并尝试添加新的它没有添加它编辑数据表中的最后一行
p:dataTable clearFilters() after creating new row and delete it, and try to add new one it didn't added it edit last row in the datatable
当我尝试删除数据中的现有行时 table 它已成功删除。但是,一旦我尝试在同一会话中添加新行,它就会编辑 table 中的最后一行,但它已经添加到列表中。
<p:dataTable id="AllData" var="itemTypeVar" value="#{itemTypeBean.itemTypesList}" sortBy="#{itemTypeVar.itemTypeId}"
editable="true" paginator="#{common.paginator}" rows="#{common.rows}"
paginatorTemplate="#{common.paginatorTemplate}"
rowsPerPageTemplate="#{common.rowsPerPageTemplate}"
paginatorPosition="#{common.paginatorPosition}" styleClass="sClass ui-datatable-hor-scroll"
widgetVar="allData">
<p:column headerText="#{docBundle.delete}" style=" height: auto;width:60px;text-align: center;">
<p:commandLink action="#{itemTypeBean.delete(itemTypeVar)}" update=":Form_Data:AllData :Form_Mesages" oncomplete="PF('allData').clearFilters()" />
<p:commandButton actionListener="#{itemTypeBean.addRecord}" id="add" value= "#{docBundle.add}" update=":Form_Data :Form_Mesages" style="margin-top: 5px;" oncomplete="jQuery('.ui-datatable-data tr').last().find('span.ui-icon-pencil').each(function(){jQuery(this).click()}); " />
豆子:
public void delete(InvStpItemType deleted) {
RequestContext context = RequestContext.getCurrentInstance();
itemStpTypeCurrent = new InvStpItemType();
itemStpTypeCurrent = deleted;
try
{
if (itemStpTypeCurrent.getItemTypeId() != 0) {
invStpItemTypeFacade.remove(deleted);
itemTypesList.remove(itemStpTypeCurrent);
Messages.deleteSuccMsg(this.getLanguage());
} else {
itemTypesList.remove(itemStpTypeCurrent);
}
}
catch(Exception ex)
{
Messages.errorMsg(getLang(), "canNotDeletedUsedByItems");
}
}
public void addRecord() {
if (!addRecord) {
addRecord = true;
itemStpTypeCurrent = new InvStpItemType();
itemStpTypeCurrent.setActive("A");
itemTypesList.add(itemStpTypeCurrent);
Utilities.getLastPagination(":Form_Data:AllData");
}
else{ Utilities.getLastPagination(":Form_Data:AllData");}
}
I removed ' oncomplete="PF('allData').clearFilters()" ' from my ْXHTML code and reset the datatable from my ْBean code and it works well... if u have a better solution don't hesitate to post it .
DataTable dataTable = (DataTable)FacesContext.getCurrentInstance().getViewRoot().findComponent(":Form_Data:AllData");
dataTable.reset();
当我尝试删除数据中的现有行时 table 它已成功删除。但是,一旦我尝试在同一会话中添加新行,它就会编辑 table 中的最后一行,但它已经添加到列表中。
<p:dataTable id="AllData" var="itemTypeVar" value="#{itemTypeBean.itemTypesList}" sortBy="#{itemTypeVar.itemTypeId}"
editable="true" paginator="#{common.paginator}" rows="#{common.rows}"
paginatorTemplate="#{common.paginatorTemplate}"
rowsPerPageTemplate="#{common.rowsPerPageTemplate}"
paginatorPosition="#{common.paginatorPosition}" styleClass="sClass ui-datatable-hor-scroll"
widgetVar="allData">
<p:column headerText="#{docBundle.delete}" style=" height: auto;width:60px;text-align: center;">
<p:commandLink action="#{itemTypeBean.delete(itemTypeVar)}" update=":Form_Data:AllData :Form_Mesages" oncomplete="PF('allData').clearFilters()" />
<p:commandButton actionListener="#{itemTypeBean.addRecord}" id="add" value= "#{docBundle.add}" update=":Form_Data :Form_Mesages" style="margin-top: 5px;" oncomplete="jQuery('.ui-datatable-data tr').last().find('span.ui-icon-pencil').each(function(){jQuery(this).click()}); " />
豆子:
public void delete(InvStpItemType deleted) {
RequestContext context = RequestContext.getCurrentInstance();
itemStpTypeCurrent = new InvStpItemType();
itemStpTypeCurrent = deleted;
try
{
if (itemStpTypeCurrent.getItemTypeId() != 0) {
invStpItemTypeFacade.remove(deleted);
itemTypesList.remove(itemStpTypeCurrent);
Messages.deleteSuccMsg(this.getLanguage());
} else {
itemTypesList.remove(itemStpTypeCurrent);
}
}
catch(Exception ex)
{
Messages.errorMsg(getLang(), "canNotDeletedUsedByItems");
}
}
public void addRecord() {
if (!addRecord) {
addRecord = true;
itemStpTypeCurrent = new InvStpItemType();
itemStpTypeCurrent.setActive("A");
itemTypesList.add(itemStpTypeCurrent);
Utilities.getLastPagination(":Form_Data:AllData");
}
else{ Utilities.getLastPagination(":Form_Data:AllData");}
}
I removed ' oncomplete="PF('allData').clearFilters()" ' from my ْXHTML code and reset the datatable from my ْBean code and it works well... if u have a better solution don't hesitate to post it .
DataTable dataTable = (DataTable)FacesContext.getCurrentInstance().getViewRoot().findComponent(":Form_Data:AllData");
dataTable.reset();