0

I have an annoying problem with Matlab coding: I have created a uitable which store values and I have implemented a function for highlight the number in cells in particular conditions. This has been done giving an html command, the problem is that after the setting of new colour the number from a "double" becomes a "cell" and updating the data in the table it highlights correctly the value, but aligns all the numbers to the left; instead I would like to keep them constantly on the right. I tried everything without positive results; I think is enough to add the alignment command in the html syntax, but somebody can give me some suggestion?

This is the part of the code:

tab = findobj('Tag',tab_name);
valrow = cellstr(num2str(tab.Data(index,1))); %number in the cell has to be highligthed
color = [1 1 0.4]; %yellow
clr = dec2hex(round(color*255),2)'; clr = ['#';clr(:)]';
valrow = strcat(...
          ['<html><body bgcolor="' clr '"text="#010101; font-weight: width=100px">'],...
          valrow);     %html code for highlight the number
fulltab = cellstr(num2str(tab.Data(:,1)));    %transform all the data in the table from double to cell
fulltab(index,1) = valrow;    % switch the old value in the tab with the same value highligthed
set(tab,'Data',[fulltab]);

As I said previously, this code works but put all the data in the table from right usual alignment to the left.

user692942
  • 16,398
  • 7
  • 76
  • 175
  • please post runnable code, where all variables are defined. Please tell us what you've tried while you "I tried everything", so we don't need to try it again. What's wrong with adding the alignment command to the html syntax, does it not work? – Robert Seifert Feb 02 '15 at 13:31
  • also you've read [this](http://undocumentedmatlab.com/blog/uitable-cell-colors)? – Robert Seifert Feb 02 '15 at 13:33
  • Okay, in detail this is a ButtonDownFcn callback; briefly I have axes with scattered 3 dimensional points inside and the value are stored in the table. Once I click with the mouse on the point inside axis, the callback find out the value in the table (I have omitted this fist part of code in the question because is not relevant; anyway I use 'currentpoint' property on axis for identifying the correct value), handle the table with the tag name and the final part of the code is there attached. I tryed to put something like: – user4519587 Feb 02 '15 at 14:01
  • ' and similar combination of the syntax, reading about html coding, but running the callback it seems to not recognise the align command, continuing to put all the numbers on the left. – user4519587 Feb 02 '15 at 14:07

1 Answers1

0

I had the same problem... then I realized the width was set at 100% not the actual cell width. Once I made the correction the text was aligned within the width setting.

CellVal = strcat('',MaxOver,'');