Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SAPUI5 model sorter sort responsive table by multiple columns

Tags:

sapui5

Hi I have a responsive table with data and I need to sort it using the following two columns

  1. PONumber
  2. PO Line

The problem is the model sort is only working with a single property. How to sort the table data by the above order.

This is my view

<m:Table id="podetailstable" items="{ path: '/PODetails' , sorter: { path: 'PoNumber'  } }">
                                                <m:columns>
                                                    <m:Column>
                                                        <m:Text text="{i18n>poDetails_tablecol_PoNumber}"/>
                                                    </m:Column>
                                                    <m:Column>
                                                        <m:Text text="{i18n>poDetails_tablecol_PoLine}"/>
                                                    </m:Column>

                                                    <m:Column>
                                                        <m:Text text="{i18n>poDetails_tablecol_PoItemQty}"/>
                                                    </m:Column>

                                                </m:columns>
                                                <m:items>
                                                    <m:ColumnListItem>
                                                        <m:cells>
                                                            <m:Text text="{PoNumber}"/>
                                                            <m:Text text="{PoLine}"/>

                                                        <m:Text text="{PoItemQty}"/>



                                                        </m:cells>
                                                    </m:ColumnListItem>
                                                </m:items>
                                            </m:Table>
like image 911
tarzanbappa Avatar asked Oct 26 '25 17:10

tarzanbappa


1 Answers

To sort with 2 columns simply add an array of sorter objects:

The below

sorter: { path: 'PoNumber'  }

becomes

sorter: [{
        path: 'PoNumber', 
        descending: false
    }, {
        path: 'PoLine', 
        descending: false
    }]
like image 116
Bernard Avatar answered Oct 29 '25 08:10

Bernard



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!