how to use tree in app designer

30 Ansichten (letzte 30 Tage)
pipor
pipor am 8 Sep. 2023
Bearbeitet: Adam Danz am 8 Sep. 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

Antworten (2)

Shoresh Shokoohi
Shoresh Shokoohi am 8 Sep. 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 Kommentar
Adam Danz
Adam Danz am 8 Sep. 2023
SelectedNodes indicates which nodes are currently selected (in blue, below), not which nodes are checked.

Melden Sie sich an, um zu kommentieren.


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

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by