Link two row in a table

1 view (last 30 days)
Cristian Martin
Cristian Martin on 31 Aug 2022
Answered: Seth Furman on 3 Sep 2022
In a GUI a have two tables , trough a button when select a row from the upper table it send to the bottom table like this:
D=get(handles.uitable1,'Data');
Index=get(handles.uitable1,'UserData');
a = D(Index.Indices(:,1), :);
old_data=get(handles.uitable4,'Data');
old_data = array2table(old_data);
new_data = [old_data; a];
set(handles.uitable4, 'Data',new_data);
I have two perform an extra action , so when the user push that button an dialog window ask him if he want to link a new entry from the upper table with an existing one from the second table and if he is agree to force the user to select a row from the second table.
I tried to do something like this:
D=get(handles.uitable1,'Data');
Index=get(handles.uitable1,'UserData');
a = D(Index.Indices(:,1), :);
answer = questdlg('Link entry?', ...
'Atention !', ...
'YES','NO','No thank you');
switch answer
case 'YES'
%%% HERE I DONT KNOW TO FORCE USER TO SELECT A ROW FROM uitable4
D=get(handles.uitable4,'Data');
Index=get(handles.uitable4,'UserData');
variable_for_further_purpose = D(Index.Indices(:,1), :); % This I will use for further_purpose
%%%
old_data=get(handles.uitable4,'Data');
old_data = array2table(old_data);
new_data = [old_data; a];
set(handles.uitable4, 'Data',new_data);
case 'NO'
old_data=get(handles.uitable4,'Data');
old_data = array2table(old_data);
new_data = [old_data; a];
set(handles.uitable4, 'Data',new_data);
end
Thanks !

Answers (1)

Seth Furman
Seth Furman on 3 Sep 2022
In App Designer and apps created with the uifigure function, uiconfirm is recommended over questdlg because it provides additional customization options.

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Products


Release

R2015a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!