[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.rcp] Re: Changing contents of ComboCellBoxEditor dynamically

Hi Swapnil,

That is just the case I was talking about. You may need some code like follows, say your model class is MyModel.

tableViewer.addSelectionChangedListener(new ISelectionChangedListener(){
   public void selectionChanged(){
       MyModel myModel = (MyModel)((IStructuredSelection)tableViewer.getSelection).getFirstElement();
       if(...) // row1 selected {
           comboBoxCellEditor.setItems(new String[]{"A", "B", "C"});
       }else{
           comboBoxCellEditor.setItems(new String[]{"A", "B"});
       }
   }
});


I think you can implement the logic for determine whether you should set [A,B,C] or [A,B].




Hi Allen,

Thanks for the reply. I have another problem around
ComboBoxCellEditor. I want to set different items in comboBox for each
row ,so lets say I have a Column 'Column1' which is of type
ComboBoxCellEdior and I have 2 rows 'Row1' and 'Row2'. Now when 'Row1'
is shown in tableViewer the Column 1 should be populated with values
"A","B","C" and for 'Row2' the same 'Column 1' should be populated
with values "A","B". How this can be done ? .

Thanks and Regards,
Swapnil
Allen Young wrote:

Hi Swapnil,

I should add a ISelectionChangedListener to you TableViewer. Then you
could change the ComboCellBoxEidtor's items n the listener's
selectionChanged(...) method. You can simply get the String[] of the
items you want and using ComboCellBoxEidtor's setItems(...) method.
This is what I usually do and it works for me. I hope this could be
helpful.

Allen.

Hi all,

I have implemented a TableViewer from a table which contains 2
columns.
In each column (and every rows) I have a ComboBoxCellEditor. I need
to
change the content of the ComboBox in the column2 when the selection
change in the ComboBox of the column1. How can I do that ? . As far
as
I think If I set the contents of ComboBoxCellEditor with some values
then those can be never changed and are applicable to every row.
Thanks & Regards,
Swapnil