When to Use
- Display hierarchical data (organizational structure, regions, menus, categories)
- Checkbox tree + cascade selection + read selected nodes
- Node click/expand events, asynchronous lazy loading of child nodes
Before You Start
- Which syntax? F.js / Pro / Core-MVC / Core-RazorForms / Core-RazorPages / Java (for determination see
fineui-foundation)。 - Where do the nodes come from? Hard-coded statically / built in backend code (C#
Tree.Nodes.Add(new TreeNode{...})or ViewBag; JavaTree1.addNode(node)+node.addChild(child))/ asynchronous lazy loading. - Do you want checkboxes?
checkbox(F.js) /EnableCheckBox(C#) /enable-check-box(Java) + cascadeCascadeCheck/cascade-check。
Quick overview of each syntax (one static tree)
// ① F.js —— rootNode.children 挂节点,节点是 JSON 对象
F.create({
type: 'Tree', isFluid: true, id: 'Tree1', renderTo: '#wrap', height: 300, title: '树控件',
rootNode: { expanded: true, children: [
{ text: '中国', id: 'china', expanded: true, children: [
{ text: '河南省', id: 'henan', children: [
{ text: '驻马店市', id: 'zhumadian' },
{ text: '漯河市', id: 'luohe' }
] }
] }
] }
});
<%-- ② Pro(WebForms):<Nodes> 里 <f:TreeNode> 嵌套 --%>
<f:Tree ID="Tree1" runat="server" IsFluid="true" ShowHeader="true" Title="树控件">
<Nodes>
<f:TreeNode Text="中国" NodeID="china" Expanded="true">
<f:TreeNode Text="河南省" NodeID="henan" Expanded="true">
<f:TreeNode Text="驻马店市" NodeID="zhumadian" />
<f:TreeNode Text="漯河市" NodeID="luohe" />
</f:TreeNode>
</f:TreeNode>
</Nodes>
</f:Tree>
// ③ Core-MVC(Fluent API)
@(F.Tree().IsFluid(true).ID("Tree1").ShowHeader(true).Title("树控件")
.Nodes(
F.TreeNode().Text("中国").NodeID("china").Expanded(true).Nodes(
F.TreeNode().Text("河南省").NodeID("henan").Expanded(true).Nodes(
F.TreeNode().Text("驻马店市").NodeID("zhumadian"),
F.TreeNode().Text("漯河市").NodeID("luohe")
)
)
))
<!-- ④ Core-TagHelper(RazorForms / RazorPages,写法相同)-->
<f:Tree ID="Tree1" IsFluid="true" ShowHeader="true" Title="树控件">
<Nodes>
<f:TreeNode Text="中国" NodeID="china" Expanded="true">
<f:TreeNode Text="河南省" NodeID="henan" Expanded="true">
<f:TreeNode Text="驻马店市" NodeID="zhumadian" />
</f:TreeNode>
</f:TreeNode>
</Nodes>
</f:Tree>
<!-- ⑤ FineUI.Java(Thymeleaf 方言:标签/属性全 kebab-case;节点用 <f:nodes> 包裹)-->
<f:tree id="Tree1" is-fluid="true" show-header="true" title="树控件">
<f:nodes>
<f:tree-node text="中国" node-id="china" expanded="true">
<f:tree-node text="河南省" node-id="henan" expanded="true">
<f:tree-node text="驻马店市" node-id="zhumadian"></f:tree-node>
</f:tree-node>
</f:tree-node>
</f:nodes>
</f:tree>
The Java structure corresponds exactly to Core-RazorForms: container
<f:tree>, child node collection tag<f:nodes>(Core is<Nodes>), node<f:tree-node>. All attributes are kebab-case (is-fluid/show-header/node-id); the initially selected node uses the container attributeselected-node-id="..."。
Documentation Reference Files
| File | When to read |
|---|---|
| references/nodes-data.md | Node attributes, icons, backend node construction, data binding (DataSet recursion) |
| references/checkbox-events.md | Checkbox tree/cascade/read selected, node click/expand events, asynchronous lazy loading |
Related Skills
fineui-foundation: syntax determination, naming conventionsfineui-window: pop up an edit window after a tree node is clicked
Constraints & Rules
- Determine the syntax first, do not mix: F.js node attributes are camelCase (
text/id/expanded);C# TreeNode PascalCase(Text/NodeID/Expanded);Java tag attributes are kebab-case (text/node-id/expanded). F.js usesid, C# usesNodeID,Java tags usenode-id—but Java'sTreeNodeBean usesgetId()/setId(...)(notNodeID)。 - Cascade selection is
CascadeCheck/cascade-check: notAutoCheckParent/AutoCheckChildNodes(these do not exist). - To read selected nodes use
GetCheckedNodes()(C# returnsTreeNode[];JavagetCheckedNodes()returnsList<TreeNode>); there is noGetCheckedNodeIDs. F.js clientgetCheckedNodes(true)。 - The way to read selected items differs by syntax:RazorForms / Java uses the control field
Tree1.GetCheckedNodes()/Tree1.getCheckedNodes(); MVC/RazorPages use the clientgetCheckedNodes(true)serialized and posted backJArray. See references/checkbox-events.md。 - Lazy loading uses
OnNodeLazyLoad/on-node-lazy-load+AutoLeafIdentification="false"/auto-leaf-identification="false"+ nodeLeaf/leaf(notEnableAjax);Leaf=falselazy loading is triggered when the node expands,Leaf=trueis a leaf. - Node client actions use
ClickHandler/click-handler: the value only writes the page's named function, with signature(event, nodeId); explicitly returningfalsecan cancel subsequent default actions and server-side events. Do not writeOnClientClick/on-client-click。 - Never fabricate APIs: if unsure, check the official website API or
F/doc/JSDoc。
Official Resources
- Online API: JS https://fineui.com/js/api/ · Pro https://fineui.com/pro/api/ · Core https://fineui.com/core/api/