从 SmartTable 中删除过滤器选项

May*_*ena 2 sapui5

我们已经实现了一个 SmartTable,一切正常。我只想删除 SmartTable useTablePersonalisation 选项提供的过滤器选项。

这可能吗 ?

问候, 玛雅克

mar*_*ner 7

您可以从 SmartTable 的嵌入式 P13nDialog 中删除过滤器(和所有其他选项),customData如下所示SAPUI5 探索示例:P13nDialog with disabled 'Filter' tab - Variation

SmartTableWithoutFilterOption.view.xml

<core:View xmlns:core="sap.ui.core" xmlns="sap.ui.comp.smarttable"
    xmlns:html="http://www.w3.org/1999/xhtml"
    xmlns:customData="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1"
    controllerName="my.namespace.SmartTableWithoutFilterOption">

    <SmartTable
        tableType="ResponsiveTable" header="A bunch of data"
        enableAutoBinding="true" entitySet="RecordSet"
        customData:p13nDialogSettings='{filter:{visible:false}}' />
</core:View>
Run Code Online (Sandbox Code Playgroud)

请注意,您需要声明属性才能工作的xmlns:customData命名空间customData:p13nDialogSettings

但是您也可以使用更长的customData聚合表示法。

SmartTableWithoutFilterOptionLongNotation.view.xml

<core:View xmlns:core="sap.ui.core" xmlns="sap.ui.comp.smarttable"
    xmlns:html="http://www.w3.org/1999/xhtml"
    controllerName="my.namespace.SmartTableWithoutFilterOptionLongNotation">

    <SmartTable
        tableType="ResponsiveTable" header="A bunch of data"
        enableAutoBinding="true" entitySet="RecordSet">
        <customData>
            <core:CustomData
                key="p13nDialogSettings"
                value='\{
                    "filter": \{ "visible": false}
                }' />
        </customData>
    </SmartTable>
</core:View>
Run Code Online (Sandbox Code Playgroud)

要隐藏其他选项,请使用columns,sortgroup代替filter。您还可以组合这些设置来隐藏多个选项。以下代码将只允许过滤。

<core:CustomData
    key="p13nDialogSettings"
    value='\{
        "columns": \{ "visible": false},
        "sort": \{ "visible": false},
        "group": \{ "visible": false}
    }' />
Run Code Online (Sandbox Code Playgroud)