Reputation: 31
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.
Upvotes: 3
Views: 1787
Reputation: 13945
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:
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!
Upvotes: 0