如何在 SAP UI5 Smart Table 中实现初始排序 [英] How to implement initial sorting in SAP UI5 Smart Table

查看:41
本文介绍了如何在 SAP UI5 Smart Table 中实现初始排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个智能表,里面有一些自定义列.我想根据某个字段对表格进行初步排序,我该如何实现?

I have a smart table, with some custom columns inside it. I would like to sort the table initially based on a certain field, how do I achieve it?

到目前为止,我已经尝试了以下方法,但没有奏效.

Till now I have tried the following, but it didn't work.

var oSmartTableBatches = this.getView().byId("sapAffectedBatchesSmartTable2");

    oSmartTableAlerts.applyVariant({
        sort: {
            sortItems: [{
                columnKey: "FieldName",
                operation: "Descending"
            }]
        }
    });

我也试过用 Presentation Variant 注释实体集

I have also tried annotating the entity set with Presentation Variant

   <Annotation Term="com.sap.vocabularies.UI.v1.PresentationVariant">
    <Record>

        <PropertyValue Property="SortOrder">
            <Collection>
                <Record>
                    <PropertyValue Property="Property" PropertyPath="FieldName"/>
                    <PropertyValue Property="Descending" Boolean="true"/>
                </Record>
            </Collection>
        </PropertyValue>
    </Record>
</Annotation>

我使用的是 odata v2 模型.

I am using odata v2 model.

我也尝试使用 beforeRebindTable 函数添加排序器,但是它破坏了表格个性化对话框,并且分组和过滤不再适用于表格.

I also tried using beforeRebindTable function add a sorter, however it breaks the table personaliation dialog, and grouping and filtering doesn't work on table anymore.

推荐答案

排序器必须是 sap.ui.model.Sorter 对象的数组,请参阅 文档.

The sorter must be an array of sap.ui.model.Sorter objects, see the documentation.

这篇关于如何在 SAP UI5 Smart Table 中实现初始排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆