I have a question regarding inserting data from edit into a table. As it is now, a new row appears with the data that I wrote in the textboxes. My problem is the first row.. it is blank.
Thanks in advance
function tablerows
% Test dynamic addition of rows
close all
clc
figure
emptyRow = {'','',''};
tableData = emptyRow;
g=uitable('ColumnEditable', true(1,3), ...
'Data',tableData,'CellEditCallback',@editCallback);
uicontrol('style','pushbutton',...
'position' ,[100 0300 100 50],...
'callback', @kort)
w=uicontrol('style','edit',...
'position' ,[400 220 100 30]);
q=uicontrol('style','edit',...
'position' ,[400 320 100 30]) ;
e=uicontrol('style','edit',...
'position' ,[400 120 100 30]);
function kort (hObjects,eventdata)
old=get(g,'data')
newrow={get(q,'string') get(w,'string') get(e,'string')}
new=[old;newrow]
set(g,'data',new)
if get(g,'data')=={'', '' ,''}
set(g,'data',newrow)
else
set(g,'data',new)
end
end
end