uitable formatting (cell borders, color,comma style)

Hello,
Questions on uitable:
1) how to add cell borders on the table(data area)? I tried to use findjobj, but not sure which one to call in here http://www.mathworks.com/matlabcentral/fileexchange/14317
2) how to add color on column and row header(not the BackgroundColor/ForegroundColor), if it is possible.
3) how to change data format, so instead of 2e+04, I prefer 20,000 (the comma style)
Anyone knows how to code all that? Thanks in advance!

 Respuesta aceptada

You can use HTML in the columnname parameter.
columnname = {'<FONT color="green">Rate</FONT>', ....}
The leading '<HTML>' must be present for this to work.
I do not know that you can affect the cell borders. You could experiment with using HTML for the data cell array (which requires that the entries be strings), but since the HTML affects only one cell at a time, I do not know if you will be able to affect the borders.

4 comentarios

Yes, you are right~ In my case, I will just use
columnname = {'<BODY bgcolor="green">Rate</FONT>', ....}
Thank you, again!
You would probably want /BODY instead of /FONT
In practice the closing HTML tags can be left off:
'<HTML><BODY bgcolor="green">Rate'
it's just the string which is colored, then if you have string with differents length, you will have different colored width, which is not presentable
Zoe Zhang
Zoe Zhang el 13 de Ag. de 2012
right, thanks~~

Iniciar sesión para comentar.

Más respuestas (2)

Babak
Babak el 13 de Ag. de 2012

1 voto

Open the GUI with GUIDE first, then double click on the table. A window named property inspector will open up.
Property inspector for uitable has a few options like "column editable". If you click ont he right side of this option, a new window named "Table Property Editor" opens up.
In the forth pane of this window you can setup the colors.
In the first pane named "columns" you can see the columns you have created (or if you have not yet created any column you can start creating them here) there is a place where it says "Format" where if you click on the optionsyou can change the data type of the data you put in the columns.you can even create a custom data type.
Hope that helps but I don't understand why one needs to add grid in the cells of the table and never heard of it.

4 comentarios

Zoe Zhang
Zoe Zhang el 13 de Ag. de 2012
Thanks for your quick reply. Do you know how to do 1 and 2 programmatically?And for the grid, I meant the cell borders. Thanks!
Hi Zoe, Here is an example from MATLAB's documentation: Pay attention to columnformat logical for the format of the data in the table. You can create a similar table propert named: "BackgroundColor" and then set the background color of the cells with this option. Now I understand what you want to do with the borders of cells but I don't know how I never seen this option in GUIDE.
f = figure('Position',[100 100 400 150]);
dat = {6.125, 456.3457, true, 'Fixed';...
6.75, 510.2342, false, 'Adjustable';...
7, 658.2, false, 'Fixed';};
columnname = {'Rate', 'Amount', 'Available', 'Fixed/Adj'};
columnformat = {'numeric', 'bank', 'logical', {'Fixed' 'Adjustable'}};
columneditable = [false false true true];
t = uitable('Units','normalized','Position',...
[0.1 0.1 0.9 0.9], 'Data', dat,...
'ColumnName', columnname,...
'ColumnFormat', columnformat,...
'ColumnEditable', columneditable,...
'RowName',[]);
Zoe Zhang
Zoe Zhang el 13 de Ag. de 2012
Editada: Zoe Zhang el 13 de Ag. de 2012
Thanks Babak, I am actually doing the same thing. But after I ran this exact same example on help, I found the result on my computer differ from what I see in the help. And the differences are 1 and 2, which are my questions. In the example, the row header is in grey but mine is just in white (Q2). Also there are cell borders in the example, but mine has no border (Q1).
Zoe Zhang
Zoe Zhang el 13 de Ag. de 2012
i am not sure whether it is due to version difference. But just to clarify again, I am asking for ways to change color on the column and row header, not the BackgroundColor. And I am asking for the cell border for the data area.
Thanks!

Iniciar sesión para comentar.

% h=uitable(...)
to set a color
set(t,'BackgroundColor',[.8 .5 .9],'ForegroundColor',[0 1 0]);
%[0 1 0] RGB color

2 comentarios

Zoe Zhang
Zoe Zhang el 13 de Ag. de 2012
Hi Azzi, I am looking for ways to change color on the column and row header, not the BackgroundColor/ForegroundColor. Do you know ways of doing that? Thanks!
Zoe Zhang, did you find any solution to the above question you've asked? I need to change the font color of each row with different colors without using 'uistyle' and 'addStyle'. Also, html code doesn't seem to be working with uifigure (works with figure);

Iniciar sesión para comentar.

Categorías

Más información sobre App Building en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 13 de Ag. de 2012

Comentada:

el 19 de Mayo de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by