-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UITable unsupported #15
Comments
Did you see the provided Table Demo for an example of how to edit tables? A table is actually a collection of many different elements (mainly headers and cells), each with its own handle. I know of no way to modify a collection of cells (in this case a column) in one go - you'll have to find handles to every individual cell and update each of them separately, as is done in the demo. I'll look into this to see if there's a way to do what you want... |
Thanks a lot! The table demo only changes the border of the modify button to red after clicking it. I assume, that iterating through all the cells of a column one by one and setting a background color would be possible too, if that helps in researching this issue. |
Hmm, I suppose this is because the table demo was developed on a later MATLAB version, which changed some aspects of uifigures. Is updating the MATLAB version a possibility for you? The way I usually go about "uncovering" the right way to modify elements is to dump the HTML code, and then explore it in a browser. You can do it using the following code: uiFig = uifigure();
mlapptools.setTimeout(uiFig,15);
tbl = uitable(uiFig);
H = mlapptools.getHTML(uiFig);
dataTag = char(struct(struct(tbl).Controller).ProxyView.PeerNode.getId); Then copy the contents of In R2017b, the DOM node related to the <div class="mw_type_Table mw_type_TableBase mw_type_ListBase mw_type_DataGrid
mw_type_Component hideRowHeaders hideColumnHeaders showCellBorders hideVerticalScroll
hideHorizontalScroll mgg arrayTable gbtTable"
id="mgg_b76f1aa0" widgetid="mgg_b76f1aa0" data-tag="datatools.variableeditor.views.table"> So now the question is how to get a In any case, I would advise against working with empty tables as this is needlessly complicated. |
Since its an older group project I'm working on, I'm limited to using 2016b... |
Small update - I took a long look at this yesterday and tried various ways to get the @t2m4k1 - before the tool can be updated, I first need to know the function H = issue15
uiFig = uifigure();
mlapptools.setTimeout(uiFig,15);
uitable(uiFig,'Data', magic(3));
mlapptools.waitForFigureReady(uiFig);
pause(3); % to be on the safe side
H = mlapptools.getHTML(uiFig); % should be about 24k characters long then put the output in an I'm leaving this be for now due to a lack of ideas. P.S. |
@t2m4k1 I have just pushed a commit which is supposed to make it easy to apply styles to specific cells. Be advised that:
Using the code in the commit message, % Create figure:
uiFig = uifigure('Position', [100 100 800 130]); mlapptools.setTimeout(uiFig,15);
hT(1) = uitable(uiFig,'Data', magic(3), 'Position', [020 020 300 80]);
hT(2) = uitable(uiFig,'Data', magic(4), 'Position', [350 010 400 100]);
% Get IDs:
ID1 = mlapptools.getTableCellID(hT(1), 1:3, 1:3 ); % select diagonal
ID2 = mlapptools.getTableCellID(hT(2), 1:4, 3*ones(1,4)); % select column
pause(5); % Wait a bit to ensure tables are ready.
% Apply styles:
hWW = mlapptools.getWebWindow(uiFig);
arrayfun(@(x)mlapptools.setStyle(hWW, 'background', 'red', x), ID1);
arrayfun(@(x)mlapptools.setStyle(hWW, 'background', 'yellow', x), ID2); I hope this could prove useful to you. |
@Dev-iL - I think that it should be simple enough to modify mlapptools.setStyle(hWW, 'background', 'red', ID1);
mlapptools.setStyle(hWW, 'background', 'yellow', ID2); |
@altmany Thanks for the suggestion. I have incorporated it into the latest experimental commit (for now, only in % Handle the case of a non-scalar ID_obj recursively:
if ~isscalar(ID_obj)
arrayfun(@(x)mlapptools.setStyle(win, styleAttr, styleValue, x), ID_obj);
else
... Do what we did previously |
Expected Behavior
Hello together,
my ultimate goal is to change the background color of a single column in a uitable.
Therefore I'd like to modify the uitable's style. Is this currently possible / will it be supported in a future release of mlapptools? I attached a little code-sample showing that even basic operations on uitables are currently not working for me.
Thanks in advance,
Thomas
Actual Behavior
Warning: This widget is unsupported.
In mlapptools/getWidgetID (line 390)
In mlapptools.getWebElements (line 134)
In mlapptools.fontColor (line 70)
Output argument "ID_obj" (and maybe others) not assigned during call to "mlapptools/getWidgetID".
Error in mlapptools.getWebElements (line 134)
widgetID = mlapptools.getWidgetID(win, mlapptools.getDataTag(uiElement));
Error in mlapptools.fontColor (line 70)
[win, ID_struct] = mlapptools.getWebElements(uiElement);
Steps to Reproduce the Problem
uiFig = uifigure();
mlapptools.setTimeout(uiFig,15);
tbl = uitable(uiFig);
mlapptools.fontColor(tbl, 'aqua');
Specifications
The text was updated successfully, but these errors were encountered: