Does anyone know how to update a songle row of a datatable?
I have a scrollable datatable where you can see e.g. 20 rows. When you scroll down to e.g. row 60 and click on it details are shown in a Panel and you can edit the selected model. Pushing on the save button writes the data to the db and the row is updated in the list.
But if I update the list from the command button the complete list is redrawn and the first row is visible again. The user ha to scroll down again to see the results in the list. This is an undesired behaviour.
I want to update a single row and not the redraw the complete list.
Code: Select all
<h:form id="list-form">
<p:dataTable id="model-list" scrollable="true" scrollHeight="250"
value="#{programmaBean.models}" var="model" rowKey="#{model.seq}"
selectionMode="single" selection="#{programmaBean.selectedModel}"
style="background-color: #f5f5f5">
<p:ajax event="rowSelect" listener="#{programmaBean.onRowSelect}" update=":programma-info-panel :ddv-panel" />
Code: Select all
<p:panel id="ddv-panel" header="DDV-planning">
<h:form id="ddv-form">
<p:toolbar id="resources-toolbar">
<p:toolbarGroup align="left">
<p:commandButton value="Bewaren" actionListener="#{programmaBean.saveModel}" update="upload-naar-npo-medewerker :list-form:model-list" />
</p:toolbarGroup>
</p:toolbar>
<h:panelGrid columns="2">
I want to redraw a single row.
PS I searched for hours on the internet but nothing I could use or I recognize that is useful for me.
Code: Select all
public void onRowSelect(SelectEvent e) {
DataTable component = (DataTable) e.getComponent();
int row = component.getRowIndex();
currentModel = ((Programma) e.getObject());
}