JavaFX - TableView - Keep Position in List After Applying Predicate - javafx

General question from someone relatively new to JavaFX. I'm sure there has to be a simple solution. I have a large observable list (10,000 items). I'm wrapping that as a FilteredList and using it in a Tableview. When a button is clicked, I apply a predicate that hides a portion of the items - maybe every third item. When clicked again, the predicate is cleared.
My issue is this. The user pages through the Tableview/FilteredList to item 500. The item doesn't have focus and isn't selected but is the first item shown in the view. They click the button and one-third of the items are hidden. The tableview is redisplaced starting at the 500th item in the FilteredList - much deeper in the list.
I would like the list to redisplay showing the approximate location from before predicate was applied. For example, if item 500 was not removed by the filter, I would like it to be the first item show after the redisplay. If it was filtered, then I would like item 501 to be the first item redisplayed. In essence, I would like the items showing that are not filtered before the predicate is applied to show after the predicate is applied. If it’s displaying the following before:
500
501
502
503
504
and 500 and 502 are filtered, I want it to display
501
503
504
505
506
Not the following
710
711
712
713
714
I hope that makes sense. I don't need a complete example of how to do this but I sure could use someone to point me in the right direction.

Related

Can tree column be hidden programmatically in TreeTableView of JavaFX?

I have a useful TreeTableView GUI view definition builder and would like to use in on tabular data where I don't need drill downs. I tried ...
m_treeTableView.getTreeColumn().setVisible(false);
... but it doesn't hide the tree column. Any help?
getTreeColumn appears to be returning null regardless of the thread or delayed execution I call it from. However, the column exists at index zero in the TreeTableView vector of columns. Hiding it by index works fine but gives unpredictable results if drill-down is defined.
However, TreeTableView hides the column automatically and elegantly if no drill-down is defined - logical behaviour and exactly what I need.
Edit: getTreeColumn returns null even if the column is not null, but is at its default position, leftmost place. Otherwise it returns the column.

QTreeView multiple issues (row hover highlights, child row highlights, row selection with multiple columns)

Versions
pyqt5
python 3.6
Setup
I'm having a few issues with the QTreeView class.
The QTreeView is configured as:
treeView.setSelectionBehavior(QAbstractItemView.SelectRows)
treeView.setSelectionMode(QAbstractItemView.SingleSelection)
There are no custom style sheets on this QTreeView
I've implemented a custom model for the view, and the flags() definition is:
def flags(self, index):
if not index.isValid():
return 0
f = super(RecordTreeModel, self).flags(index)
f = f | Qt.ItemIsSelectable | Qt.ItemIsEnabled
return f
Is there anything else relevant to the situation? I'm not doing anything fancy with my model. No custom painting, no special selection requirements -- everything is straight out of basic model examples besides the way the data structure is accessed.
Issues
Row Selection
When clicking on any column besides the first column, the row will not be selected.
Column Hovering
When hovering over any column besides the first column, the row will not be highlighted
Child Hovering
No child rows are ever highlighted when the mouse hovers over them.
I've been banging my head (and google's search bar) against these problems for several hours, to no avail.
Please let me know if I can provide any additional information!

how to reduce web page size with many select controls

I'm working on an asp.net application that allows the user to update data for a series of days. The data is presented as a table:
Date - Active - Active Promotion
04/11/11 - yes - listbox with 360 entries
05/11/11- yes - listbox with 360 entries
06/11/11 - yes - listbox with 360 entries
...
04/02/12 - yes - listbox with 360 entries
Now, the table can have from 90-700 rows (eg allow entry for 90-700 days) and the select box has 360 entries (12,000 characters). So, for a 3 month display, I get the page size of 90 * 12,000 = 1MB and this increases to 8.4MB for a 2 year display.
I can see that the problem is the many repeated listbox . I have thought of the following approaches, perhaps people can suggest improvements or refinements:
Have each listbox populate itself when clicked (reduces initial page size but user may have to wait for drop down to populate)
Have one 'real' listbox and many 'fake' listbox . when the user clicks on a 'fake' listbox the 'real' listbox is then displayed, the selected value is then stored in a hidden field
get the client to cleanup the data so there aren't 300+ options in each box
If the options are the same for every listbox, I would definitely suggest auto-populate with javascript on clicking. I've used this solution before for exactly the same reason, and there is no perceptible delay in popping up the select list, and the original page loads way faster.
Also Firefox used to have a bug when handling lots of large select elements, and the javascript populate when necessary solution also sidestepped that.
I would go with something like the second option. What you can also do is to populate the first one initially, and then copy the contents to others using JavaScript.
But otherwise - seems you got some usability problems to solve, who's gonna use such monster forms!? :)
I would limit input to one month at a time and store it in memory until ready to complete the transaction back to the DB. I would also review choice of control for this, that is, instead of a listbox think of something more intuitive; possibly a calendar with text boxes - you could use tabs and move from one month to the next.

UITableViewController indexPathForSelectedRow returns incorrect value

I'm not sure what is going on but I have a list that has 3 items and I am selecting row 1.
I am using a viewcontroller that is a UITableViewController and that has a property tableView where I am accessing the indexPathForSelectedRow during the didSelectRowAtIndexPath.
For some reason this value is incorrect sometimes...
What could cause this?
The UITableView * param on didSelectRowAtIndexPath is also called tableView.
If your table has more than one section that can confuse things (it's caught me before). indexpath.row will return the row number in the section of the table, not the row number of the overall table. If that's not what you're expecting it'll appear wrong.

Odd paging problem with DataGrid and sorting

I have a data table that is being filled by a stored procedure. I need to filter down the results some, so I get a data view from the default view and apply a row filter to it. I then bind this to my DataGrid. All is fine at this point. I see two pages (17 records with 10 per page). If i apply a sort to the grid though, it now shows 5 pages (58 records without the filter). I stepped through the code and it repopulates the data prior to running the sort. The repopulation is with with the filter in place and it counts 17 records, but shows 5 pages.
To make it even weirder, if I click on a page i know will be invalid, it runs the page change (which also repopulates the data) and this time it limits the pages to 2 and tells me i have an invalid page number!
Any ideas?
It was the custom control causing the problem. We have an AutoDataSource function that automatically pulls the data tables out of my view and sorts on them. I found a filter function in my grid that apply the filter, but only if applied before setting the datasource
Make sure to apply the sort to the default view and not the grid column directly.

Resources