cancel
Showing results for 
Search instead for 
Did you mean: 

Sort sap.m.table again

dirk_wieczorek
Participant
0 Kudos

Hello,

i got at question concerning the sap m.table.

I have an application with table with with colummns.

A, B, C, D ,E.

The table is sorted by A.

I have an f4 value help wich allows the user to change the value of  column A.

The colummn contains

HS02

HS06

HS08

HS10

After changing HS02 to HS09

HS09

HS06

HS08

HS10

The table is not sorted by column a anymore.

Is there a way to refresh the sorting /actualize the sorting of the table after the change?

If so how?

Best regards.

Dirk

Accepted Solutions (1)

Accepted Solutions (1)

former_member182372
Active Contributor
0 Kudos
dirk_wieczorek
Participant
0 Kudos

Its an XML Model.

I have bound a sorter to the model when i create the table.

Is it possible to call that again like Model.sort() or do i have to write a custom sort function?

I just need to resort the table after making changes to it.

Best regards.

dirk

saivellanki
Active Contributor
0 Kudos

Hi Dirk,

Wherever you have placed the value change logic (make sure your model is also updated with the change value), next to that try something like this -


var oSorter = new sap.ui.model.Sorter("A");               //A is your column name

var oTable = this.getView().byId("oTable");          //Get Hold of table control, if it is not MVC use sap.ui.getCore().byId("oTable")

var oBinding = oTable.getBinding("items");

oBinding.sort(oSorter);

Regards,

Sai Vellanki.

saivellanki
Active Contributor
0 Kudos

Dirk,

I have created a JSBin for you, check it here: JS Bin - Collaborative JavaScript Debugging

Try to change the product column value and hit enter, it will automatically sort. I have used JSON model, but the sort logic remains same for XML model as well.

Regards,

Sai Vellanki.

former_member182372
Active Contributor
0 Kudos

ClientListBinding has method applySort

just do mTable.getBinding("items").applySort()

dirk_wieczorek
Participant
0 Kudos

Thanks for the help.

Problem solved.

I didnt know that the sort is part of the binding. I looked at the model assigned to the table and tehre was no sort.

regards.

Dirk

former_member182372
Active Contributor
0 Kudos

applySort is not good, it doesnt fire an event, so UI is not getting notified when to rerender

Answers (1)

Answers (1)

former_member182372
Active Contributor
0 Kudos

sort method of the binding should do i trick. model is json or odata?