Skip to Content
0

Initial Filter SmarTable SAPUI5

Apr 13 at 06:32 PM

43

avatar image
Former Member

I'm trying to set an initial sort for the SmarTable component, but it's only applied visually. Below is my code.View:
<smartTable:SmartTable entitySet="CustomerOrders" id="tbOrders" tableType="Table" useExportToExcel="true" beforeExport="onBeforeExport"
				header="Ordens de Manutenção" showRowCount="true" enableAutoBinding="true" beforeRebindTable="onBeforeRebindTable"
				initiallyVisibleFields="PriorityName,OrderTypeType,OrderTypeName,Id,DateOpen,HourOpen,BrandName,EquipmentId,EquipmentNumber,SymptomName"
				class="sapUiResponsiveContentPadding">

Controller:
onBeforeRebindTable: function(oEvent) {
    var oSmartTable = oEvent.getSource();
    if (this._isOnInit == null) this._isOnInit = true; //To set this initial sorter only when view start
    if (this._isOnInit) {
        oSmartTable.applyVariant({
            sort: {
                sortItems: [{
                        columnKey: "PriorityName",
                        operation: "Ascending"
                    }
                ]
            }
        });
        this._isOnInit = false;
    }
},


But only show the order icon and.


The correct order:
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Desiree Matas
Apr 16 at 10:13 AM
0

Hi Marcos,

What do you mean with "but it's only applied visually"? I understand the sort is applied but not in the way you want? What is the behavior and the expected one? The SAPUI5 version you are using would be useful too.

Best regards,

Désirée

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Desiree.
I mean that the sorter has only applied visually because they put a sorter icon in the column header, but does not apply the sorter in the rows in table. The first screenshot is how the table gets when I do it the way it is in the code. Already the third image is the result that would wait with the sorter.

0
Former Member

Now i add this to the onBeforeRebindTable method and worked 100%, thanks to guy in stackoverflow.
https://stackoverflow.com/questions/49823490/sapui5-apply-initial-sort-for-smarttable/49832501#49832501

var oParameters = oEvent.getParameter("bindingParams");
				oParameters.sorter = [
					new sap.ui.model.Sorter("DateOpen", false),
					new sap.ui.model.Sorter("PriorityId", false),
					new sap.ui.model.Sorter("HourOpen", false)
				];

0