How does getSourceData handle order?

Tags: #<Tag:0x00007f8b1cfacb30>

I feed the json data into the table in one order, but I display the table in a different order. After I make a change to the table, if I log getSourceData(), the order of the new json data follows the order of how it was fed in, not how it is displayed.

I load the data in this order: date, lock, rooms_sold
but I display in this order: date, rooms_sold, lock

If you select ‘lock’ and click the button, the output of getSourceData() shows the change to the data, but it is in the order [date, lock, rooms_sold].

Why isn’t the outputted data in the new order that I am displaying the table? Is this just how getSourceData() handles changes?

Hey @nirmalmulji

to get the whole dataset you can manipulate with two methods getData and getSourceData. You already know the source, the getData will return what you see (besides renderers).

1 Like

getData result

0: (3) ["Tue, 04/30/2019", 34, false]
1: (3) ["Wed, 05/01/2019", 14, false]
2: (3) ["Thu, 05/02/2019", 66, false]

yes but getSourceData also returns the manipulated data, but it is in the other order. My question is why does this occur with getSourceData. I use getSourceData in my application and want to make sure it doesn’t change in the future.

If you’d like to get exactly what you have in the dataObject array, you’d need to make a copy of this variable. Simply asking for this value won’t work as it is assigned by the reference.

1 Like