How to add a sortable property to uitable within a classic figure.
2 ビュー (過去 30 日間)
古いコメントを表示
I am running matlab 2018 and 2019. Once a uitable created and populated I have tried some customisation without any success
function JavaCustom(hTable)
jscroll=findjobj(hTable);
jtable=jscroll.getViewport.getView;
%change background color of a given column k to red
k=1;
cr=javax.swing.table.DefaultTableCellRenderer;
%set color
cr.setBackground(java.awt.Color(1,0,0));
jtable.getColumnModel.getColumn(k-1).setCellRenderer(cr);
jtable.repaint;%update
%sorting
%jtable.setSortable=true;==> error
jtable.setSortingEnabled(true);
% jtable.setAutoResort=true;==> error
% jtable.setMultiColumnSortable=true;==> error
% jtable.setPreserveSelectionAfterSorting=true;==> error
jtable.setSortOrderForeground(java.awt.Color.blue);
jtable.setShowSortOrderNumber(true);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Any idea?
1 件のコメント
Walter Roberson
2019 年 7 月 4 日
This is not supported. You might be able to get it to work.
You should probably poke around http://undocumentedmatlab.com to see if Yair has written about this.
採用された回答
Yair Altman
2019 年 7 月 5 日
My Java-based uitable utility on the Matlab File Exchange provides a sortable wrapper for the legacy uitable. The sorting functionality is provided by the TableSorter Java class, which is included in the submission.
An alternative is to use coderazzi's TableFilter, which provides both filtering and sorting in a single class.
I discuss uitable sorting in detail on:
- my Undoumented Matlab website (https://undocumentedmatlab.com/blog/uitable-sorting)
- section 4.1.4 of my book "Undocumented Secrets of Matlab-Java Programming"
- and [in most detail] in my uitable customization report
3 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Use COM Objects in MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!