3

To generate a ui-table I'm using GUIDE. To insert a popup menu into the ui-table I'm using the following code(for example):

data = {1;2;3,'A';'B';'C'}   
set(handles.uitable,'ColumnFormat',{'1','2','3'},'char',data)

Then i will get the same popup menu in every row of the ui-table. But I want to have different popup menus in different rows of a ui-table, as shown in the picture below.

http://images.undocumentedmatlab.com/uitable_lookup.png

Dominique
  • 1,080
  • 14
  • 29
  • [different question](http://stackoverflow.com/q/19406767/2605073) but contains the [code you need](http://stackoverflow.com/a/19569951/2605073). The general way to do it would be like in the linked question, but you will get the same problems like I did. So you need to introduce independent rows as described in the linked answer. – Robert Seifert Oct 21 '14 at 16:47

1 Answers1

0

If I understood correctly, you want to set the 'ColumnEditTable' property of selected columns to true during the creation of your table, and depending of the columnformat you specify you can get popupmenus or checkboxes for example.. Consider this code, which I modified form the doc (look here)

function MyTable

f = figure('Position',[300 300 400 400]);

% Column names and column format
columnname = {'Greeting','Amount','Available','Fixed/Adj'};
columnformat = {{'Hello' 'Hi'},'bank','logical',{'Fixed' 'Adjustable'}}; %// Set the entries of the popup menu in a cell array. When the format is 'logical', the output in the table is a checkbox.

% Define the initial displayed data
d =    {'Hi'  456.3457  true   'Fixed';...
        'Hello'   510.2342  false  'Adjustable';...   
        'Hi'      658.2     false  'Fixed';};

% Create the uitable
t = uitable('Data', d,... 
            'ColumnName', columnname,...
            'ColumnFormat', columnformat,...
            'ColumnEditable', [true false true true],... %// That's the important line. Entries set to true will allow you to create a popup menu for the whole column.
            'RowName',[]);

The table looks like this:

enter image description here

As you can see you can select 'Hi' or 'Hello' in the first columns and either 'Fixed' or 'Adjustable' in the last column.

Hope it gets you started and it's somewhat what you wanted!

Benoit_11
  • 13,905
  • 2
  • 24
  • 35