App Designer: Format headings on uitable

조회 수: 47 (최근 30일)
Samuel Thompson
Samuel Thompson 2018년 1월 9일
편집: Eric Delgado 2023년 6월 19일
The table below is a uitable created within App Designer that has been modified using the following code:
app.UITable2.ColumnName = {'node iD', 'X', 'Y', 'Z'};
app.UITable2.ColumnWidth = {80, 80, 80, 80};
nodeindex = (1:1:length(app.D.Coord))';
nodeid = num2cell(nodeindex);
Xcoord = num2cell(app.D.Coord(1,:)');
Ycoord = num2cell(app.D.Coord(2,:)');
Zcoord = num2cell(app.D.Coord(3,:)');
app.UITable2.Data = [nodeid Xcoord Ycoord Zcoord];
I wish to do two things:
  1. Format the column headers (modify text font and weight, text colour and background)
  2. Centrally align the data within the table.
Any help would be appreciated. I have searched through the documentation and other similar answers but have found nothing as of yet that seems to work.
Thanks in advance, Sam

답변 (2개)

Eric Delgado
Eric Delgado 2023년 6월 19일
편집: Eric Delgado 2023년 6월 19일
I am not sure if it is still an issue to you guys, but I wrote ccTools, a lib that turns possible the customization of the header of the uitable (and a lot of more things, like a new filterable table class). I hope it helps! :)
f = uifigure;
g = uigridlayout(f, 'RowHeight', {'1x'}, 'ColumnWidth', {'1x'});
t = uitable(g, 'Data', table("#"+string((1:100)'), (1:100)', (1:100)'+.1, (1:100)'+.001, (1:100)'+.00001, randn(100,1)));
drawnow
ccTools.compCustomization(t, 'backgroundHeaderColor', '#52555c', ...
'borderRadius', '10px', ...
'fontFamily', 'Times New Roman', ...
'color', 'white');

ES
ES 2018년 1월 9일
편집: ES 2018년 1월 9일
You can use html to format the headings, values in table!
You may start here https://undocumentedmatlab.com/blog/gui-formatting-using-html
  댓글 수: 3
Ramiro Massol
Ramiro Massol 2021년 1월 29일
HTML is not yet recognized in AppDesigner R2020b, so no way yet to format column/row headers in uitable.
Adam Danz
Adam Danz 2021년 5월 25일
This answer shows how to create a UITable within a UIFigure (eg, app designer) that appears to have formatted column names. It moves the column names into the first row of the data and the applies formatting to make it appear as though the first line of data is actually a table header. The same logica can be applied to row names.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by