Skip to Content
0

how to make single column editable in smart table

Apr 26, 2017 at 12:39 PM

555

avatar image
Former Member

Hi Experts,

am trying to create a smart table which needs to have an editable column. We are using the OData metadata to generate the columns in smart table. We have smart table property (editable = "true") which is making all columns in table are editable. But i need to have only single column as editable column. Please find the screenshot for sample screen.

Kindly suggest how we can achieve this.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

avatar image
Former Member Nov 13, 2017 at 03:05 PM
1

You need a few things in place to control the editing of fields in your SmartTable

  • TwoWay binding mode
  • editTogglable="true" attribute on your SmartTable
  • customData:useSmartField="true" on your SmartTable
  • fieldChange="onFieldChange" on your SmartTable
  • Updatable tick box on your Entity Set in SEGW transaction
  • Updatable tick box for the specific fields on your Entity Type in SEGW transaction

Notes:

customData namespace is defined in your view xml

xmlns:customData="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1"

onFieldChange is defined in your view controller file and would contain the logic to set changes back to your webservice

onFieldChange: function(evt) {
  var change = evt.getParameter("changeEvent");
  if (change) {
    var newValue = change.getParameter("newValue");
    var src = change.getSource();
    // get the data binding and send the changes via your appropriate web service
  }
},

There are few ways to define TwoWay binding on an OData model, one is to add defaultBindingMode to your manifest file

"models": {
  "": {
    "dataSource": "myDataSource",
    "settings": {
      "useBatch": false,
      "defaultBindingMode": "TwoWay"
    }
  }
},
Share
10 |10000 characters needed characters left characters exceeded
Akhilesh Upadhyay Apr 26, 2017 at 03:23 PM
0

I think you can define customData for this column and use "enabled" property to input field. check below link if it helps.

https://sapui5.hana.ondemand.com/explored.html#/sample/sap.ui.comp.sample.smarttable.mtableCustom/code/SmartTable.view.xml

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Akhilesh,

Thanks for the help. With 'CustomData' we were able to create custom fields in smart table.

0

please mark this as right ans to help others for same issue.

0
avatar image
Former Member Jun 01, 2017 at 11:49 AM
0

Hello Yarragudi,

Did you find the solution ? I am facing the same issue.

Thanks in advance.

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Farouk,

We can create custom fields in smart table.

Please follow the link given by Akhilesh.

sample code: create a table inside smart table like below.

<Table> <columns> <Column width="100px" hAlign="Left"> <customData> <core:CustomData key="p13nData" value='\{"columnKey": "Dmbtr", "maxLength": "5","columnIndex":"4", "leadingProperty": "Dmbtr"}' /> </customData> <Text text="{/#LineItems/Dmbtr/@sap:label}" /> </Column> </columns> <items> <ColumnListItem> <cells> <Text text="{Dmbtr}" /> </cells> </ColumnListItem> </items> </Table>

Regards,

Chandra

1
avatar image
Former Member Jul 05, 2017 at 11:56 PM
0

Hi,

I am facing the same issue, I would like to edit the rows I select as editable and then change the values and post them into the database. Please help.

Share
10 |10000 characters needed characters left characters exceeded