Author |
Message |
cone
Joined: 29 May 2007 Posts: 356
|
|
TableReorder didn't work properly |
|
Hi,
i am not shure if the beahaviour is a bug but for me it seems so.
The TableReorder seems not to work if i have a Table with or without a sortTableModel.
Only if i use a FilterTableModel then the selection of a cell gets automatically restored with TableReorder#reselectTableRows when i fire a tableDataChanged().
In any other circumstances the cells gets deselected.
Kind regards,
michael
|
|
Thu Dec 07, 2017 2:48 am |
|
 |
cone
Joined: 29 May 2007 Posts: 356
|
|
|
|
Hi support,
can you write something for this problem?
Maybe it is no problem and i have to do something more?
Kind regards,
michael
|
|
Wed Dec 13, 2017 3:53 am |
|
 |
support
Joined: 21 Feb 2006 Posts: 1463
|
|
|
|
Hi,
I couldn't find a problem with TableReorder in the case where a FilterTableModel is not present. You can try this in the demo with:
 |
 |
//models
originalModel = dataModel;
ListTableModel ltm = otm;
//FilterTableModel ftm = new FilterTableModel(ltm);
SortTableModel stm = new SortTableModel(ltm);
//set class variables
sortTableModel = stm;
//filterTableModel = ftm;
model = createTableModel(stm); |
Just uncomment lines with FilterTableModel and feed the listtablemodel into the SortTableModel, instead of the FilterTableModel.
Also uncomment line fhm.attachToTable() :
 |
 |
PopupFilterHeaderModel fhm = new CustomPopupFilterHeaderModel();
//attach filter to table
//fhm.attachToTable(table, ftm); |
TableReorder restores table's selections correctly.
Maybe you have some other model other than ListTableModel?
Thanks
|
|
Wed Dec 20, 2017 8:04 am |
|
 |
cone
Joined: 29 May 2007 Posts: 356
|
|
|
|
That's curious because i did the same thing in your demo.
Additionally i do the following in AbstractDemoPanel
 |
 |
public JButton btnFireDataChanged;
protected JPanel createVerticalTableFeaturePanel() {
...
//create the panel
JPanel featurePanel = new JPanel(new BorderLayout());
featurePanel.add(panel);
// NEW CODE
btnFireDataChanged = new JButton("fireDataChanged");
btnFireDataChanged.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
originalModel.fireTableDataChanged();
}
});
}
I select a cell and click on the button and the cell is not selected anymore (except when i use a filterTableModel).
Tested this again with version 4.9 !?
|
|
|
Tue Jan 02, 2018 3:07 am |
|
 |
support
Joined: 21 Feb 2006 Posts: 1463
|
|
|
|
Hi,
FilterTableModel has variable 'clearOnDataChanged' which is false by default, so this is why it does not assume that data has actually changed after a TableDataChanged event. If you set this variable to true, it will clear all selections after the event is fired.
But normally, a TableDataChanged event implies that all the data of the table have changed, so one would expect the selections to be cleared as well. In FilterTableModel there is the option to keep the selections since it was easy to implement, but in SortTableModel I am not so sure. But why don't you use fireTableRowsUpdated instead?
|
|
Thu Jan 04, 2018 6:22 am |
|
 |
cone
Joined: 29 May 2007 Posts: 356
|
|
|
|
Ahh, i did not realize that.
In my apps i worked with filtertablemodel and found it comfortable that the selection gets automatically restored on tabledatachanged.
well than i had to do the same like you do in the filtertablemodel if there was no filtertablemodel.
|
|
Thu Jan 04, 2018 8:54 am |
|
 |
cone
Joined: 29 May 2007 Posts: 356
|
|
|
|
But when you think that it is only usefull to reselect a filteredTableModel why is a TableReorder instanciated in AdvancedJTable?
But on tableChanged the selection didn't get reselected because reselectTableRows are allways null?
And to make the confusion complete...if i use a treeTable on tableChanged a the TableReorder gets an fireRowsReordered and the selection gets restored.
|
|
Fri Jan 05, 2018 2:22 am |
|
 |
cone
Joined: 29 May 2007 Posts: 356
|
|
|
|
Hi,
can you please respond to my last comment.
Did you think that the curretn behaviour works well or do you plan to implement the same behaviour in every table (probably with an overall parameter like clearOnDataChanged)?
Kind regards,
michael
|
|
Mon Mar 05, 2018 5:13 am |
|
 |
support
Joined: 21 Feb 2006 Posts: 1463
|
|
|
|
Hi,
The clearOnDataChanged makes sense only for ListTableMap classes like SortTableModel and FilterTableModel. I will try to add the same functionality to SortTableModel, as it is missing.
Also for TreeTables, a TreeTableReorder is used.
|
|
Wed Mar 07, 2018 6:27 am |
|
 |
cone
Joined: 29 May 2007 Posts: 356
|
|
|
|
any news for this bug?
|
|
Mon Dec 03, 2018 1:05 am |
|
 |
|