How to use applyVariant function on smarttables?

血红的双手。 提交于 2019-12-19 10:14:51

问题


How can I use applyVariant function on a smarttable?

The documentation exist here:

https://sapui5.hana.ondemand.com/sdk/#/api/sap.ui.comp.smarttable.SmartTable/methods/applyVariant

But it does not say what the structure of oVariantJSON parameter should be!!!


回答1:


Just try to apply a filter on your smart table and in the beforeRebindTable event of your smart table try to use the following code:

onBeforeRebindTable: function(oEvent) {
   var oSmartTable = oEvent.getSource();
   console.log(oSmartTable.fetchVariant());
}

By using the fetchVariant function, you can see what the structure of the variation is. For example for filter it is like this:

{
     filter: {
                    filterItems: [{
                        columnKey: "YourSelectedColumn",
                        exclude: false, 
                        operation: "EQ", 
                        value1: "SomeEnteredValue",
                        value2: ""
                    }]
                }
}

Then you can use this object for the applyVariant function as its first parameter.



来源:https://stackoverflow.com/questions/48620541/how-to-use-applyvariant-function-on-smarttables

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!