Azzera filtri
Azzera filtri

how to use tree in app designer

20 visualizzazioni (ultimi 30 giorni)
pipor
pipor il 8 Set 2023
Modificato: Adam Danz il 8 Set 2023
i want to know what is selected or not:
Jow is not selected
Linda is not selected
where can i find this information? ...
this my code in callBack
function Tree_EquitySelectionChanged(app, event)
nodes = app.Tree_Equity.SelectedNodes;
if ~isempty(nodes)
data = [nodes.NodeData];
display(sum(data));
disp(data)
end
end

Risposte (2)

Shoresh Shokoohi
Shoresh Shokoohi il 8 Set 2023
The code you've provided seems to correctly identify the selected nodes and display some information about them.
Here's a breakdown of your code:
1. `app.Tree_Equity.SelectedNodes` retrieves a list of selected nodes in the `Tree_Equity` tree component.
2. The `if ~isempty(nodes)` condition checks if there are any selected nodes. If there are selected nodes, it proceeds to the next steps.
3. `data = [nodes.NodeData];` extracts the data associated with each selected node. This assumes that each node has a `NodeData` property that contains relevant information.
4. `display(sum(data));` calculates the sum of the data associated with selected nodes and displays it. This step may not be necessary for your specific task, as it doesn't directly relate to determining which nodes are selected.
5. `disp(data)` displays the data associated with each selected node in the command window.
The information you want to extract from the selected nodes is not entirely clear from your code, but you are correctly accessing the selected nodes and displaying the associated data.
If you want to determine which specific nodes are selected and whether their data indicates selection status (e.g., "selected" or "not selected"), you need to examine the structure of the `data` associated with each node. Ensure that the `NodeData` property of each node contains the necessary information to identify whether it is selected or not, and then adjust your code accordingly.
  1 Commento
Adam Danz
Adam Danz il 8 Set 2023
SelectedNodes indicates which nodes are currently selected (in blue, below), not which nodes are checked.

Accedi per commentare.


Adam Danz
Adam Danz il 8 Set 2023
Modificato: Adam Danz il 8 Set 2023
Look in app.Tree_Equity.CheckedNodes.
SelectedNodes indicates which nodes are currently selected (in blue, below), not which nodes are checked.

Categorie

Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by