[BUG] Perspective table selection data doesn't update after applying a filter

Ignition version 8.1.20

When a filter is applied to my perspective table the selection data property does not update. If I clear the filter it still does not update my selection data unless I refresh the page. I’ve added a label at the bottom of the screen with its text prop bound to the first column of the selected data in the table.

image

When running the designer in preview mode I have tried manually clearing the value of the filter text property and the elements of data in the results property however the issue remains.

I am also no longer able to open any of my popups where the table selection data are passed in as parameters, which is strange - I would have thought the popups would still open but just with the ‘out of date’ selection data (as per what is displayed on the label)



Hi @amy.thompson, what version of Ignition are you using? Also, does the same behavior happen in the designer? Like can you select items in the table and watch the selection object change?

Sorry forgot to mention in the post, 8.1.20. The behaviour in the designer is the same, after filtering the table the selection object does not change value

That is very strange because I have a simple setup that mimics yours (version included) and it works as expected. As you said, the popup should open even if the value is stale. Do the logs show you any error messages? Can you try clicking the button that opens the popup in the designer and see if you get messages in the console?

No errors from within the designer or in the logs. I tried one of my other similar pages which has a much smaller dataset in the table and it seems to work. I wonder if I’m hitting an limit somewhere in terms of table size? There are 8500 rows returned from the query bound to this table (hence wanting the filter function)

There isn’t a table size limit as far as I know (I haven’t hit it anyway) and we’ve had more than 10,000 rows in it before. If you want to test whether it is the table size, just LIMIT 100 on your query and see if that helps. I’m wondering if the selection data does change, but it just takes forever. Is your table bound to a query that returns your table data or are you populating it another way?

I want to make sure I understand. I think you are saying that you are using a Perspective table and you set “props.filter.enabled” to true.

I loaded up 8.1.20 on a fresh install and drug a perspective table onto the screen. It comes with a dataset containing 50 rows.

I ran the screen in the designer so I could watch property values and selected the 3rd row and typed “sa” in the filter. This retained row 3 as the selected row but I could not see row 3. The dataset still contains 50 rows but the table component is only showing 7 of them.

I cleared my filter and repeated the experiment but I selected row 5 (“San Diego”) and applied the same “sa” filter. This reduced the displayed records to the same list but row 5 is showing as selected.

So what I’m saying is that you still have whatever row you clicked on selected but you’re telling the table to hide the row using a filter.

Does this explain what you’re seeing or am I misunderstanding your setup?

Edit:
I noticed a property “props.filter.results.enabled”. If you set that to true it will populate “props.filter.results.data” with a dataset containing the visible rows in the table.

If this is what you’re trying to do and you want it to select the first record when the filter changes you could do something like this…

  1. Add a custom property to the control and bind it to “this.props.filter.results.data”
  2. Add a script transform to it to look up the index of the first displayed record assuming your data is uniform (which it isn’t in the default data on the control.
    Example for the default created control:
	data = self.props.data
	find = value[0].city
	i = 0
	
	for item in data:
		if item['city'] == find:
			self.props.selection.selectedRow = i
			return i
		i += 1

Notice the script sets “self.props.selection.selectedRow” when it finds a match. This particular script will return an error for the first record in the sample data because it is formatted differently than the rest of the data. This is a proof of concept version so to speak :slight_smile:

The idea is to use the binding of the filter results to drive a script call to update the selected. Of course, you could use the same strategy to select nothing when a filter is entered.

Anyway, I thought that may be helpful for what I think you’re trying to do.

I think this might be it. My table data is bound to a named query. I modified the named query with a TOP 100 to limit the results and it works as expected. I guess filtering on a table this large is a slow process…

1 Like