datatable inline editing doesn't update other rows
I am trying to use datatable inline editing which has checkbox as one of the columns, the req is user is supposed to select only one checkbox. I have code in backing bean for rowEditListener which iterates through the list and set boolean value to false for remainng elements. Backing bean values are updated successfully but after update, however previous checkbox remains checked during rendering. How to display values of other updated rows using inline editing ?
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
There is onRowEditUpdate you can use to update whole datatable. By default row edit event only updates edited row.
Below is the code, I tried onRowEditUpdate="rpTable"
specifying datatable id but didn't work, I still see previous checkbox selected.
<p:dataTable id="rpTable"
var="rp"
value="#{bean.routePointList}"
rowEditListener="#{bean.onRowRPEdit}"
onRowEditUpdate="rpTable"
rowIndexVar="rowIx">
specifying datatable id but didn't work, I still see previous checkbox selected.
<p:dataTable id="rpTable"
var="rp"
value="#{bean.routePointList}"
rowEditListener="#{bean.onRowRPEdit}"
onRowEditUpdate="rpTable"
rowIndexVar="rowIx">
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
Try 3.0 snapshot or update a wrapper component of datatable like a parent outputPanel.
- bumble.bee
- Posts: 723
- Joined: 29 Sep 2010, 21:39
- Location: United States
You can't use the onRowEditUpdate attribute to update the entire table because the DataTableRenderer only renders the edited row on a row edit.
I wanted to update the footer on row edit so I created a patch to do so. See this thread:
http://primefaces.prime.com.tr/forum/vi ... f=3&t=6063
I wanted to update the footer on row edit so I created a patch to do so. See this thread:
http://primefaces.prime.com.tr/forum/vi ... f=3&t=6063
is there any solution to update other rows of the datatable when using inline editing. We are using inline editing all over our project and we need this feature to update other rows when one row is edited. If you can find the fix for this, please reply.
- bumble.bee
- Posts: 723
- Joined: 29 Sep 2010, 21:39
- Location: United States
Closing your eyes and pretending you didn't just read the last post?
Again, you can't use PrimeFaces' inline row editing out-of-the-box to update the entire table.
You can write some code though. The referenced thread in my previous post even provides some code changes to get you started - even to naively do what you are asking.
However, if you read the (entire) thread referenced you'll see that a big problem you'll encounter is that PrimeFaces' inline row editing allows mutliple rows to be open for editing simultaneously. Each row has its own independent controls for submitting and canceling edits. Think about what this means -- if you make changes such that any given row edit updates the entire table and you have multiple rows open for editing then what do you expect to happen? Cancel all other open row edits? Submit all other open row edits? You may be better off abandoning the one-row-at-a-time inline row editing that comes with PrimeFaces and just making an entire table at-a-time solution yourself. Or - you'll need to prevent multiple rows open for editing at a time.
Again, you can't use PrimeFaces' inline row editing out-of-the-box to update the entire table.
You can write some code though. The referenced thread in my previous post even provides some code changes to get you started - even to naively do what you are asking.
However, if you read the (entire) thread referenced you'll see that a big problem you'll encounter is that PrimeFaces' inline row editing allows mutliple rows to be open for editing simultaneously. Each row has its own independent controls for submitting and canceling edits. Think about what this means -- if you make changes such that any given row edit updates the entire table and you have multiple rows open for editing then what do you expect to happen? Cancel all other open row edits? Submit all other open row edits? You may be better off abandoning the one-row-at-a-time inline row editing that comes with PrimeFaces and just making an entire table at-a-time solution yourself. Or - you'll need to prevent multiple rows open for editing at a time.
Hi,
I am having this issue, too. However, I cannot modify the PrimeFaces-source to get it solved and I didn't even manage to refresh the whole table because the table is inside a composite and I can't access the ID of its parent.
Anyway, there might be another possibility to solve the problem in my case and I was wondering if this is possible:
If I could refresh the whole content of a row (including a cell-editors "input"-part) before the row edit *starts*, this would also solve the problem.
Can I perform an update of the row on edit start?
Thank you for your help,
Philipp
I am having this issue, too. However, I cannot modify the PrimeFaces-source to get it solved and I didn't even manage to refresh the whole table because the table is inside a composite and I can't access the ID of its parent.
Anyway, there might be another possibility to solve the problem in my case and I was wondering if this is possible:
If I could refresh the whole content of a row (including a cell-editors "input"-part) before the row edit *starts*, this would also solve the problem.
Can I perform an update of the row on edit start?
Thank you for your help,
Philipp
Glassfish 3.1.2, PrimeFaces 3.4.2
I encountered this problem, too. In my case, if the user updates a value in a particular row of the table, I want to automatically update the values in two other rows. What I did is specify a rowEditListener to determine if the value on which the other two values depends gets updated, and specified a panelGroup that contains my form's buttons as the onRowEditUpdate value to show a special button that will refresh the dataTable in that case. Here is the relevant markup from my .xhtml file:
And here is my backing bean code:
Code: Select all
<p:dataTable id="assessmentDataTable" var="dataItem" value="#{assessmentDataBean.assessmentData}"
rowEditListener="#{assessmentDataBean.onEditRow}" onRowEditUpdate="buttons">
...
</p:dataTable>
<h:panelGroup id="buttons">
...
<p:commandButton id="refreshtargetmetrics" styleClass="button" value="Update Target Metrics"
action="#{assessmentDataBean.updateTargetMetrics}" immediate="true"
rendered="#{assessmentDataBean.targeEnergyUsageEdited}" update="assessmentDataTable buttons" />
</h:panelGroup>
Code: Select all
protected boolean targeEnergyUsageEdited;
public boolean isTargeEnergyUsageEdited()
{
return targeEnergyUsageEdited;
}
public void updateTargetMetrics()
{
// We don't need to do anything in here except reset the flag, because the page will
// be updating the table and refreshing the panelGroup that contains this button.
targeEnergyUsageEdited = false;
}
public void onEditRow( RowEditEvent aEvent )
{
UIComponent lComp = aEvent.getComponent();
if ( lComp instanceof DataTable )
{
DataTable lDataTable = (DataTable)lComp;
Object lRowData = lDataTable.getRowData();
if ( lRowData instanceof AssessmentDataEntry )
{
AssessmentDataEntry lEntry = (AssessmentDataEntry)lRowData;
// If this is the value we're watching for, update the dependent values and throw
// the switch that shows the special Update Target Metrics button
if ( lEntry.getDataClass().equals( DataClass.ENERGY_USAGE_SF.toValue() ) &&
lEntry.getKey1().equals( cTargetKey ) )
{
double lTargetEnergyUsage = lEntry.getDataValue();
updateTargetDataElements( lTargetEnergyUsage ); // updates values in the List that is the source of the values in the dataTable
targeEnergyUsageEdited = true;
}
}
}
}
-
- Information
-
Who is online
Users browsing this forum: No registered users and 61 guests