# Table Sorting Breaking \`event.rowIndex\`

**URL:** <https://forum.inductiveautomation.com/t/table-sorting-breaking-event-rowindex/96376>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [September 24, 2024, 3:08pm UTC](https://forum.inductiveautomation.com/t/table-sorting-breaking-event-rowindex/96376 "2024-09-24T15:08:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Colin\_Quinn](https://avatars.discourse-cdn.com/v4/letter/c/f475e1/32.png) [@Colin\_Quinn](https://forum.inductiveautomation.com/u/Colin_Quinn)\
**Post date:** [September 24, 2024, 3:08pm UTC](https://forum.inductiveautomation.com/t/table-sorting-breaking-event-rowindex/96376/1 "2024-09-24T15:08:32Z")

</div>

Hi all,

I'm running into an issue with getting an accurate row index when a user is interacting with a table. This table has both sorting and filtering enabled and I am able to access the filtered data with some code like the following:

```python
#	convert table data and filtered data into a standard list
	data = []
	if not self.props.filter.results.data:
		for i in self.props.data:
			data.append(i['value']) #some styling in the row, therefore we need to access 'value'
	else:
		data = self.props.filter.results.data

```

This works as intended by setting data to the filtered results when there are any. However, I cannot find where the sorting comes into play. For example, using the table's `onEditCellCommit` event I am able to get which row this event happened on. But the issue comes into play when I try to get that row's data while it is being sorted as it returns the original table's row value.

Does anyone have some input on where the sorted data goes or how to get accurate event data?

---

<div class="post-metadata">

**Author:** ![djs](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@djs](https://forum.inductiveautomation.com/u/djs)\
**Post date:** [September 25, 2024, 6:48pm UTC](https://forum.inductiveautomation.com/t/table-sorting-breaking-event-rowindex/96376/2 "2024-09-25T18:48:58Z")

</div>

I'd have to see your `onCellEditCommit` script to be sure, but perhaps you're using `rowIndex` where you should be using `row`.

In the table event scripts, the `row` is the index in the original data prop, while the `rowIndex` is the index on the visible (sorted/filtered) data. You should either use `rowIndex` with the filtered data, or use `row` with the original data.

---

<div class="post-metadata">

**Author:** ![Colin\_Quinn](https://avatars.discourse-cdn.com/v4/letter/c/f475e1/32.png) [@Colin\_Quinn](https://forum.inductiveautomation.com/u/Colin_Quinn)\
**Post date:** [September 25, 2024, 7:23pm UTC](https://forum.inductiveautomation.com/t/table-sorting-breaking-event-rowindex/96376/3 "2024-09-25T19:23:05Z")

</div>

I am building out the `data` list with the code above, which is a bit clunky because I am applying styles to each individual row of the table. Then in order to access the table data, I am referencing that data list with `data[event.rowIndex]`, where it does seem to reference the row that I am interacting with but not the data. Are you thinking the issue is in the way I am building out that data list and referencing that over the actual table data property?

---

<div class="post-metadata">

**Author:** ![djs](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@djs](https://forum.inductiveautomation.com/u/djs)\
**Post date:** [September 25, 2024, 7:35pm UTC](https://forum.inductiveautomation.com/t/table-sorting-breaking-event-rowindex/96376/4 "2024-09-25T19:35:52Z")

</div>

Are you trying to assign values to the rows in your `data` variable? If you want to modify your original data, you'll have to assign to the original data prop. Your `data` list might work for reading values, but it won't work for writing.

Is there a reason you're building out your `data` list first? Could you use:

```python
self.props.data[event.row]['value']

```

---

<div class="post-metadata">

**Author:** ![Colin\_Quinn](https://avatars.discourse-cdn.com/v4/letter/c/f475e1/32.png) [@Colin\_Quinn](https://forum.inductiveautomation.com/u/Colin_Quinn)\
**Post date:** [September 25, 2024, 8:06pm UTC](https://forum.inductiveautomation.com/t/table-sorting-breaking-event-rowindex/96376/5 "2024-09-25T20:06:51Z")

</div>

No, I am using the data that is in the row receiving the edit to fill out parameters in a query that updates the relating row (via UUID's) in a database.

The main reason I build out my `data` list is that I also have filters enabled on this table, and it let me standardize references to where the data should be later on in the script.

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [September 26, 2024, 4:08am UTC](https://forum.inductiveautomation.com/t/table-sorting-breaking-event-rowindex/96376/6 "2024-09-26T04:08:34Z")

</div>

`event.row`
