# dash\_table.DataTable - Determining which rows have changed

**URL:** <https://community.plotly.com/t/dash-table-datatable-determining-which-rows-have-changed/16618>\
**Category:** Dash Python\
**Created:** [December 7, 2018, 10:54am UTC](https://community.plotly.com/t/dash-table-datatable-determining-which-rows-have-changed/16618 "2018-12-07T10:54:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pratyusht](https://avatars.discourse-cdn.com/v4/letter/p/ec9cab/32.png) [@pratyusht](https://community.plotly.com/u/pratyusht)\
**Post date:** [December 7, 2018, 10:54am UTC](https://community.plotly.com/t/dash-table-datatable-determining-which-rows-have-changed/16618/1 "2018-12-07T10:54:14Z")

</div>

When we make table editable, is there a way we can know which rows have changed?

tried using data & data\_previous to compare and find out which rows have changed, but there is an issue with that, so if i am editing multiple rows assuming 3 rows, row number 1, 10 & 15 in the same sequence.

data and data previous have difference only in the last edited row. so data\_previous will have row 1 and row 10 with the updated number, and data will have all 3 rows updated 1,10 & 15. which is why i am not able to get the exact differences.

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [December 7, 2018, 3:11pm UTC](https://community.plotly.com/t/dash-table-datatable-determining-which-rows-have-changed/16618/2 "2018-12-07T15:11:59Z")

</div>

Hm, this _should_ work and I’ve used this in the previous projects as the way to determine which rows have changed.

---

<div class="post-metadata">

**Author:** ![pratyusht](https://avatars.discourse-cdn.com/v4/letter/p/ec9cab/32.png) [@pratyusht](https://community.plotly.com/u/pratyusht)\
**Post date:** [December 7, 2018, 6:52pm UTC](https://community.plotly.com/t/dash-table-datatable-determining-which-rows-have-changed/16618/3 "2018-12-07T18:52:20Z")

</div>

Something like this uses to work in dash table experiments. But this isnt.

---

<div class="post-metadata">

**Author:** ![pratyusht](https://avatars.discourse-cdn.com/v4/letter/p/ec9cab/32.png) [@pratyusht](https://community.plotly.com/u/pratyusht)\
**Post date:** [December 10, 2018, 10:11am UTC](https://community.plotly.com/t/dash-table-datatable-determining-which-rows-have-changed/16618/4 "2018-12-10T10:11:27Z")

</div>

@chriddyp - thanks for taking a look, let me know if you find something on this? have tried it a lot unable to get this work.

---

<div class="post-metadata">

**Author:** ![OtavioAcc](https://avatars.discourse-cdn.com/v4/letter/o/85e7bf/32.png) [@OtavioAcc](https://community.plotly.com/u/OtavioAcc)\
**Post date:** [November 4, 2020, 11:18am UTC](https://community.plotly.com/t/dash-table-datatable-determining-which-rows-have-changed/16618/5 "2020-11-04T11:18:41Z")

</div>

The answer took a little too long, however, it’s never too late.

This is the best way I found

```auto
@app.callback(
    Output('div-result', 'children'),
    [Input('my-table', 'data'),
     Input('my-table', 'columns')],
     [State('my-table', 'active_cell')], prevent_initial_call=True
)
def update_tol_db(rows, columns, cell):
    if(rows == None or columns == None or cell == None):
        raise PreventUpdate
    print(rows[cell['row']])
    raise PreventUpdate

```

I’m using the updated row to update my database, so this is why I’m not really updating the div.

---

<div class="post-metadata">

**Author:** ![kvdm.dev](https://avatars.discourse-cdn.com/v4/letter/k/96bed5/32.png) [@kvdm.dev](https://community.plotly.com/u/kvdm.dev)\
**Post date:** [December 20, 2022, 10:53am UTC](https://community.plotly.com/t/dash-table-datatable-determining-which-rows-have-changed/16618/6 "2022-12-20T10:53:18Z")

</div>

Seems like it works well with a single row. What is about multiple rows?

I tried to use `selected_cells` and `data` for extracting changed data, but `selected_cells` returns only one row on the paste event as if it would be only active cell.

---

<div class="post-metadata">

**Author:** ![kvdm.dev](https://avatars.discourse-cdn.com/v4/letter/k/96bed5/32.png) [@kvdm.dev](https://community.plotly.com/u/kvdm.dev)\
**Post date:** [December 20, 2022, 11:06am UTC](https://community.plotly.com/t/dash-table-datatable-determining-which-rows-have-changed/16618/7 "2022-12-20T11:06:31Z")

</div>

I ended up with detecting the changed rows by comparing `data` attribute and data queried from a database, instead of `previous_data` attribute or workaround with `selected_cells`.

It’s puts some overhead on performance but works as expected, no unsolvable Datatable bugs.
