【问题标题】:Make single column editable in a UI5 smart table在 UI5 智能表中使单列可编辑
【发布时间】:2017-06-01 11:39:03
【问题描述】:

我想创建一个带有可编辑列的智能表。我正在使用metadata 注释来生成表格。表格属性 (editable = "true") 使所有列都可编辑。就我而言,我只想让一列可编辑。我尝试使用sap:updatable="true" 属性,但没有成功。有任何想法吗。 提前致谢。 顺便说一下,这是我的看法:

<mvc:View 
    xmlns="sap.m"
    xmlns:mvc="sap.ui.core.mvc"
    controllerName="QuickStartApplication3.controller.View1"
    xmlns:smartFilterBar="sap.ui.comp.smartfilterbar"
    xmlns:smartTable="sap.ui.comp.smarttable">
    <smartFilterBar:SmartFilterBar 
        id="smartFilterBar"
        entityType="Product">
        <smartFilterBar:controlConfiguration>
            <smartFilterBar:ControlConfiguration
                key="ProductId"
                visibleInAdvancedArea="true" 
                preventInitialDataFetchInValueHelpDialog="true" >
            </smartFilterBar:ControlConfiguration>
        </smartFilterBar:controlConfiguration>

        <smartFilterBar:controlConfiguration>
            <smartFilterBar:ControlConfiguration
               key="Name"
               visibleInAdvancedArea="true" 
               preventInitialDataFetchInValueHelpDialog="true" >
            </smartFilterBar:ControlConfiguration>
        </smartFilterBar:controlConfiguration>

        <smartFilterBar:controlConfiguration>
            <smartFilterBar:ControlConfiguration
                key="Category"
                visibleInAdvancedArea="true" 
                preventInitialDataFetchInValueHelpDialog="true" >
            </smartFilterBar:ControlConfiguration>
        </smartFilterBar:controlConfiguration>

    </smartFilterBar:SmartFilterBar>

    <smartTable:SmartTable 
        id="smartTable_ResponsiveTable"
        smartFilterId="smartFilterBar" 
        tableType="ResponsiveTable" 
        editable="false"
        entitySet="Products" 
        useVariantManagement="false"
        useTablePersonalisation="true" 
        header="Products" 
        showRowCount="true"
        useExportToExcel="true" 
        enableAutoBinding="true">
    </smartTable:SmartTable>
</mvc:View>

【问题讨论】:

    标签: javascript xml sapui5


    【解决方案1】:

    我没有足够的代表来对您的问题发表简单的评论,但您能否提供您的观点示例,以便我更准确地了解您的工作?

    您是否尝试过使用文档中详述的 sap.m.Table 对象: https://sapui5.hana.ondemand.com/explored.html#/sample/sap.m.sample.TableEditable/preview

    为了只有某些单元格可编辑,您可以通过使用的模板对其进行管理,请参阅下面我如何在控制器的 onInit 方法中更改模板:

    onInit : function(evt) {
                    this.oModel = new JSONModel(jQuery.sap.getModulePath(
                            "sap.ui.demo.mock", "/products.json"));
                    this.oTable = this.getView().byId("idProductsTable");
                    this.getView().setModel(this.oModel);
                    this.oReadOnlyTemplate = this.getView().byId(
                            "idProductsTable").removeItem(0);
                    this.rebindTable(this.oReadOnlyTemplate, "Navigation");
                    this.oEditableTemplate = new sap.m.ColumnListItem({
                        cells : [ new sap.m.ObjectIdentifier({
                            title : "{Name}",
                            text : "{ProductId}"
                        }), new sap.m.Input({
                            value : "{Quantity}",
                            description : "{UoM}"
                        }), new sap.m.Input({
                            value : "{WeightMeasure}",
                            description : "{WeightUnit}"
                        }), new sap.m.Input({
                            value : "{Price}",
                            description : "{CurrencyCode}"
                        }) ]
                    });
    

    如果你不使用这个对象,那么请告诉我哪一个,我可能可以提供帮助。

    【讨论】:

    • 感谢@Almiriad 的回复,但是,我认为这不适用于智能表。如果有帮助,我编辑了我的帖子并添加了我的查看代码。
    • 你好,我看到你使用的是响应式表格类型,我觉得可以这样做,看下面的例子,使用相同的表格类型并提供表格的整个模板。 sapui5.hana.ondemand.com/explored.html#/sample/…您是否尝试过这样做并查看行为?哪些字段可编辑,哪些不可编辑?
    【解决方案2】:

    请查看“Preview”-screenshot and the metadata.xml

    如果设置 editable = "true" 并使用 sap:updatable=”false” 注释 ‘Products’ 的所有属性会发生什么, 除了应可编辑的单个属性,您将其设置为 sap:updatable=”true”。

    不要用 sap:updatable 注释实体集“产品”(或确保 sap:updatable=”true”)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-29
      • 2016-05-05
      • 2020-08-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多