cancel
Showing results for 
Search instead for 
Did you mean: 

SAP ui5 sap.ui.table column sorting not working after table refresh

vinodkumar_thangavel
Participant
0 Kudos

Hi Experts,

I have a UI table and the data is getting refreshed every 10 seconds which is mapped to a JSON model and when I try to sort my column either ascending or descending and during the data refresh the sorting is not working, So how do I keep the column sorting active all the time?

Thanks & Regards,

Vinodkumar.

junwu
Active Contributor
0 Kudos

how you refresh? how do you know the sorting is messed up by the refreshing?

vinodkumar_thangavel
Participant
0 Kudos

Hi Jun Wu,

The below code is how I am binding my data to the table and this model gets refreshed every 10 seconds,

and after refresh the data in the table column is getting updated and not sorted.

not-sorted.png

Thanks & Regards,

Vinodkumar.

Accepted Solutions (1)

Accepted Solutions (1)

junwu
Active Contributor
0 Kudos

don't create jsonmodel every time when you get new data.

you should use

yourexistingjsonmodel.setData(newData)

what does the onDataReceived do?

vinodkumar_thangavel
Participant
0 Kudos

Thank You Jun Wu creating the jsonmodel all time was the issue for sorting.

Answers (1)

Answers (1)

yogananda
Product and Topic Expert
Product and Topic Expert
0 Kudos
<Table
    id="idProductsTable"
    items="{
        path: '/data',
        sorter: {
            path: 'name',
            descending: true
        }
    }"
>
    <columns>
        <Column
            sortProperty="name"
            width="13rem">
            <Text text="Name"/>
        </Column>
        <Column
            sortProperty="category"
            width="13rem">
            <Text text="Category"/>
        </Column>
    </columns>
    <items>
        <ColumnListItem>
            <cells>
                <Text text="{name}"/>
                <Text text="{category}"/>
            </cells>
        </ColumnListItem>
    <

Just give you an sample or hint to include sorting in your data refresh logic itself.. instead of you sorting it during event refresh.

vinodkumar_thangavel
Participant
0 Kudos

Hi Yogananda,

Thanks for your valuable input.

But in my scenario the sorting made by the user at the UI level needs to remain the same even after the refresh of the data. Can you please let me know if that is possible?