GUI uitable logical values

6 ビュー (過去 30 日間)
geeks g
geeks g 2019 年 5 月 17 日
コメント済み: geeks g 2019 年 5 月 18 日
SO I HAVE this ui table i want to select sujects and push 'submit' to calculate the sum of credit for the subject i selected
i dont know how to dealing with uitable to get data from it and calculat the sum
and after that i want to push a clear' button to reset all
help please

採用された回答

Adam Danz
Adam Danz 2019 年 5 月 17 日
編集済み: Adam Danz 2019 年 5 月 17 日
"SO I HAVE this ui table i want to select sujects and push 'submit' to calculate the sum of credit for the subject i selected"
In the callback function for the "submit" button, add this section of cose. You'll need to adapt it to your gui. That means you'll need to change the variable names and the column numbers.
% I create a fake UI table just for the example
h.uitable = uitable('Data', [{false;true;true;false;false},num2cell((1:5)')], 'ColumnEdit', [true, true],'ColumnName', {'Select','Credit'});
% In my table, the check boxes are in column 1, then credits are in column 2.
% * you'll need to adapt this to your table (the variable names and column numbers)
% * These steps could be combined into 1 line but it's more intuitive this way
% Step 1) Determine which rows have checked boxes
rowChecked = [h.uitable.Data{:,1}]';
% Step 2) Get the credits for each row of checked boxes
credits = [h.uitable.Data{rowChecked,2}]';
% Step 3) add the credits
creditSum = sum(credits);
"and after that i want to push a clear' button to reset all"
In the callback function to you "clear" button, add this section of code. Again, you'll need to adapt it to your GUI.
% set all checkboxes to false
h.uitable.Data(:,1) = {false};
% Remove all credits
h.uitable.Data(:,2) = [];
  18 件のコメント
Adam Danz
Adam Danz 2019 年 5 月 18 日
Read about the 'enable' property here:
When 'enable' is turned off, the entire table is deactivated. You can't apply this to certain cells. Instead, you could change the selection available whenever a new specialtiy is chosen. For example, whenever IT is chosen the table content could change to a new list.
geeks g
geeks g 2019 年 5 月 18 日
thank you

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by