only one column with pop up window and import data into row
1 次查看(过去 30 天)
显示 更早的评论
I got it done now, that if I click on any cell a menu appears where I can select my file. But I just want this for a specific column and I also want that the filename appears in the cell in the colour blue.
For the import of the data I have to use the import-command right? If yes how can I include this into my code?
CODE:
function uitable1_CellSelectionCallback(hObject, eventdata)
datatable_row = eventdata.Indices(1);
datatable_col = eventdata.Indices(2);
Columndata = get(hObject,'Data');
[FileName,PathName] = uigetfile({'*.txt'; '*.csv'},'Select the configuration');
if strcmp(Columndata(1,1),'User Defined')
FilePath = fullfile(PathName,FileName);
if isequal(FileName,0)
return
end
[pathstr, name, ext] = fileparts(FilePath);
ParameterList{end+1} = name;
set(uitable1,'ColumnFormat',{ParameterList});
end
end
0 个评论
回答(1 个)
Jan
2017-10-18
1st question: "I just want this for a specific column"
Try this:
datatable_row = eventdata.Indices(1);
datatable_col = eventdata.Indices(2);
% Accept clicks on 2nd columns only:
if datatable_col ~= 2
return;
end
2nd question: "filename appears in the cell in the colour blue"
I have no idea, what this should do.
ParameterList{end+1} = name;
set(uitable1,'ColumnFormat',{ParameterList});
Is the name assumed to be a valid format?
Perhaps you mean
Columndata{datatable_col, datatable_row} = name;
And if you want to define the color:
str = ['<html><body color="#0000FF">', name '</body></html>']
Columndata{datatable_col, datatable_row} = str;
5 个评论
Jan
2017-10-18
You do not need Java, if you find another solution than hyper links in uitables.
Usually a uitable is used to display the contents of the file. But it is not clear yet, which data you want to display. E.g. why does the top left uitable cell contain the string 'User Defined'? What would be the purpose of the hyper link? Which function should be triggered by pressing it?
Can you create a sketch of how the GUI should look like?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!