如何在智能表sapui5中只编辑一个单元格

时间:2018-04-17 08:42:00

标签: sapui5 inline edit smart-table

我正在使用sapui5智能表来列出我的产品。它包括产品代码,产品描述和订单数量。

在这三个字段中,我只想更新订单数量。它应该是表格中的内联编辑。

在我的智能桌上,我启用了该属性" editable" as" true"。它使整行可编辑。我不想让整行可编辑,而是只想让一个单元格可编辑。

Example

 <smartFilterBar:SmartFilterBar id="smartFilterBar" entityType="ZDEMO_C_MyEntityType" persistencyKey="SmartFilter_Explored">
 </smartFilterBar:SmartFilterBar>

 <smartTable:SmartTable id="mySmartTable" 
      smartFilterId="smartFilterBar"
      tableType="GridTable" 
      editable="true" 
      entitySet="ZDEMO_C_MyEntity" 
      useVariantManagement="false" 
      useTablePersonalisation="true" 
      header="My Products" 
      showRowCount="true" 
      useExportToExcel="true" 
      enableAutoBinding="true">
 </smartTable:SmartTable>

3 个答案:

答案 0 :(得分:0)

我可以看到两种方式:

  1. 使用“字段控制”概念。它需要在实体类型中添加一个特殊属性,用于定义字段(单元格)的状态。还必须引入一些注释(在后端的metadata.xml中)以启动处理。

    以下是使用表单控件描述的概念作为示例的链接,但同样的规则也适用于https://blogs.sap.com/2017/06/06/dynamic-field-control-using-annotations-in-sapui5/

  2. 在XML中重新定义表行,并根据本地JSON模型的属性绑定所需的单元格,这可以根据需要进行更改在某些情况下(例如按下编辑按钮)。

  3. 第一种方法从架构角度来看更好,但需要一些数据模型修改(从后端方面)。

    第二种方法允许在UI上执行所有操作并编写一些复杂的UI逻辑,用于定义单元状态。

    你选择。

答案 1 :(得分:0)

您可以在智能表中添加sap ui表,并使用customdata属性添加列。请按照以下步骤操作。

  1. make editable =&#34; true&#34; as editable =&#34; false&#34;
  2. 在xml中,请务必添加此命名空间xmlns:core =&#34; sap.ui.core&#34;
  3. 在smarttable标签中添加以下内容。

    <smartTable:SmartTable .................................
    
             <Table>
                <columns>
                    <Column>
                        <customData>
                            <core:CustomData key="p13nData" value='\{"columnKey": "OrderQty", "leadingProperty": "OrderQty", "columnIndex":"2"}'/>
                        </customData>
                        <Text text="Order Qty"/>
                    </Column>
    
                </columns>
                <items>
                    <ColumnListItem>
                        <cells>
                            <Input value="{OrderQty}" type="Number" editable="true"/>
                        </cells>
                    </ColumnListItem>
                </items>
            </Table>
    
      </smartTable:SmartTable>
    

答案 2 :(得分:0)

在表格内添加以下标记,以使您的列可编辑

<table:Column sortProperty="Max_Capacity" filterProperty="Max_Capacity"  id="maxCapCol">
    <Label text="Max Capacity"/>
    <table:template>
        <Input text="{Max_Capacity}" />
    </table:template>
</table:Column>