on 2024 Jan 09 10:49 AM
Dear Fiori experts,
I have a SmartTable with a custom editable field and manual Create option. I embedded a sap.m.Table within the SmartTable with one column (checkbox) for user-selection. I didn't use standard row selection because the checkbox is controlled dynamically by backend data: it is selected by default (ABAP boolean field) and enabled/disabled by property binding of the property enabled to another ABAP boolean field.
The user checks/unchecks the field and pushes the Create button, which calls the createEntry method of the backend model (JavaScript).
In success response I call the rebindTable method of the SmartTable and the data is read again.
The problem is: the content of the editable checkbox field does not reflect the newly coming data from backend after rebindTable. The field seems to be "detached" from the model. However, the property binding for the enabled property works fine.
Does anyone have similar experience? What could be the problem?
Thanks for your ideas.
KR,
Igor
Event handler of the button "Create":
onBtnCreateOrdersPress:
function (oEvent)
{
...
var oSmtTableCreateOrders = oEvent.getSource().getParent().getParent();
// submit changes (call Batch)
oModelSAPbckOData.submitChanges({
success: function (oData, sResponse) {
oSmtTableCreateOrders.rebindTable();
},
error: function (oDataSAPerror, sResponse) {
MessageBox.show(DataSAPerror.responseText )
oSmtTableCreateOrders.rebindTable();
}
});
Fragment (irrelevant parts omitted):
<core:FragmentDefinition xmlns:core="sap.ui.core"...>
<smartTable:SmartTable
entitySet="ZCreateOrders"
tableBindingPath="to_ZC_CreateOrders"
beforeExport="onBeforeExport"
enableAutoBinding="true"
initiallyVisibleFields="auart,ilart,gewrk,aufnr,IsCreateOrder"
fieldChange="onTableFieldChange"
beforeRebindTable="onBeforeRebindTable"
ignoredFields="IsActiveEntity,DraftUUID,IsEnabled"
busy="{mod_zViewJsonModel>/IsTableBusy}"
>
<smartTable:customToolbar>
<OverflowToolbar
width="100%"
id="tlbCreateOrdersTable"
>
<content>
<Button
text="Create"
press="onBtnCreateOrdersPress"
enabled="{mod_zViewJsonModel>/IsBtnCreateOrdersEnabled}"
/>
</content>
</OverflowToolbar>
</smartTable:customToolbar>
<Table>
<columns>
<Column>
<customData>
<core:CustomData
key="p13nData"
value='\{"columnKey": "objid", "autoColumnWidth": \{ "visibleProperty": "objid" }, "columnIndex": 1, "leadingProperty": "objid", "sortProperty": "objid", "width": "100px"}'
/>
</customData>
<Label
text="Create"
/>
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<CheckBox
selected="{IsCreateOrder}"
enabled="{IsEnabled}"
select="onChbIsCreateOrderSelect"
/>
</cells>
</ColumnListItem>
</items>
</Table>
</smartTable:SmartTable>
<l:content />
</core:FragmentDefinition>
Request clarification before answering.
Hello,
I solved the problem thanks to my colleague Sandro Mathier. The values changed by the user are remembered as "Pending Changes" and therefore the fields bound to them do not react to data coming from the backend.
The solution for my case: collect all the relevant frontend changes by oModel.getPendingChanges, call oModel.resetChanges(aPathsToPendingChangesToReset) followed by a series of oModel.createEntry before I call my own custom oModel.submitChanges.
Another possible solution could be just to call submitChanges so that the App automatically sends "update" requests to the backend. It would be more simple (and maybe more correct) but it would not suit me, because I need one create call for all the rows of the table, not a series of update calls.
Maybe there are better approaches, but this one works good for me.
KR,
Igor
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
30 | |
10 | |
8 | |
8 | |
7 | |
7 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.