TableExComboBox

This is the forum for JIDE Common Layer which is open sourced at https://github.com/jidesoft/jide-oss. Please note, JIDE technical support doesn't monitor this forum as often as other forums. Please consider subscribe for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

Moderator: JIDE Support

Forum rules
Community driven forum for open source JIDE Common Layer. JIDE technical support doesn't monitor this forum as often as other forums. If you only use JIDE Common Layer, please consider subscribing for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

TableExComboBox

Postby oleg » Fri Jun 19, 2015 12:36 pm

If drop-down table has more than one row with same value in value column, how can I choose any one of those rows? Currently it returns the first one of those rows. For illustrating my question please use ShrinkSearchableDemo. Add this code:

editableTableExComboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
TableExComboBox source = (TableExComboBox) e.getSource();
int row = source.getSelectedIndex();
String symbol = (String) source.getTableModel().getValueAt(row, 0);
String name = (String) source.getTableModel().getValueAt(row, 1);
Integer volume = (Integer) source.getTableModel().getValueAt(row, 4);
System.out.println(symbol+", "+name+", "+volume);
}
}
});

And add this to DemoData as a second row:
new Object[]{"AA", "AA test", 32.88, 0.53, 1000000},
If you select the AA test I would expect printed on console: "AA, AA test, 1000000". However, it always prints "AA, ALCOA INC, 4156200". I could setValueColumnIndex(1) to make Name column to be the value column. But, it wouldn't resolve an issue if values in Symbol and Name columns are same and Volume is different. Basically, regardless of how many columns have duplicate values I want to be able to select any row among those duplicated if at least one of the.
oleg
 
Posts: 42
Joined: Thu Apr 07, 2011 10:45 am

Re: TableExComboBox

Postby JIDE Support » Mon Jun 22, 2015 6:30 am

You can call setValueColumnIndex to set a column to be used as values. The values in that column has to be unique. If your table doesn't have such a column, you can use CalculatedTableModel to create an extra column that is unique.
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37245
Joined: Sun Sep 14, 2003 10:49 am

Re: TableExComboBox

Postby oleg » Mon Jun 22, 2015 11:53 am

Then how can I make this extra column hidden? I want to use it for uniqueness with setValueColumnIndex, but not visible.
oleg
 
Posts: 42
Joined: Thu Apr 07, 2011 10:45 am

Re: TableExComboBox

Postby JIDE Support » Mon Jun 22, 2015 12:26 pm

Call TableColumnChooser.hideColumn method to hide it.
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37245
Joined: Sun Sep 14, 2003 10:49 am

Re: TableExComboBox

Postby oleg » Mon Jun 22, 2015 2:09 pm

Sorry for bothering again. CalculatedTableModel and hideColumn do the trick and I can select unique row from dropdown table.
calculatedTableModel.addColumn(new AbstractCalculatedColumn(tableModel, "calculated", String.class) {
public Object getValueAt(int rowIndex) {
return getActualModel().getValueAt(rowIndex, 0)+"_"+getActualModel().getValueAt(rowIndex, 1);
}

public int[] getDependingColumns() {
return new int[]{0,1};
}
});

However, selected row in TableExComboBox presented as "AA_ALCOA INC". I need it to contain just value of the first column "AA", but use calculated column value for filtering. I tried to override CalculatedTableModel.getValueAt() to return value of column 0, but then calculated column doesn't work.
oleg
 
Posts: 42
Joined: Thu Apr 07, 2011 10:45 am

Re: TableExComboBox

Postby JIDE Support » Mon Jun 22, 2015 2:39 pm

You can set a converter using TableExComboBox#setConverter to convert the "AA_ALCOA INC" to "AA".
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37245
Joined: Sun Sep 14, 2003 10:49 am


Return to JIDE Common Layer Open Source Project Discussion (Community Driven)

Who is online

Users browsing this forum: No registered users and 13 guests