Skip to Content
avatar image
Former Member

how to make single column editable in smart table

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

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

    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"
        }
      }
    },
    Add comment
    10|10000 characters needed characters exceeded

  • Apr 26, 2017 at 03:23 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

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

    Hello Yarragudi,

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

    Thanks in advance.

    Add comment
    10|10000 characters needed 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

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

    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.

    Add comment
    10|10000 characters needed characters exceeded