Open Closed

tree #6645


User avatar
0
nabass created

hi sir, i have a big problem now i made a query and used jsTree to make tree view and it works good but it works for just one level what i mean is one parent has 2 child what if one of these child is parent for another child what should i do? i want to make a view like image 1 and this is my query which is working good but just for one level of parent like image 2 is ABP support this feature and has a documentation link to do that or not??

ALTER PROCEDURE [dbo].[GetAccountTreeStructure2] AS BEGIN SET NOCOUNT ON;

WITH RecursiveCTE AS (
    -- Anchor member: Select root nodes (accounts with no parent)
    SELECT
        A.Id,
        A.AccountName AS ChildName,
        A.ParentAccountId,
        A.AccountLevelId,
        AL.AccountLevelTitle AS ParentName,
        0 AS Level
    FROM
        Acc_Account A
    INNER JOIN
        Acc_AccountLevel AL ON A.AccountLevelId = AL.Id
    WHERE
        A.ParentAccountId IS  NULL 

    UNION ALL

    -- Recursive member: Select child nodes recursively
    SELECT
        A.Id,
        A.AccountName AS ChildName,
        A.ParentAccountId,
        A.AccountLevelId,
        AL.AccountLevelTitle AS ParentName,
        Level + 1 AS Level
    FROM
        Acc_Account A
    INNER JOIN
        Acc_AccountLevel AL ON A.AccountLevelId = AL.Id
    INNER JOIN
        RecursiveCTE R ON A.ParentAccountId = R.Id
)

-- Final query to retrieve the tree structure with account and level information
SELECT
    Id,
    ChildName,
    ParentAccountId,
    AccountLevelId,
    ParentName,
    Level  -- Include the Level column to display the level of each node
FROM
    RecursiveCTE;

END;

  • ABP Framework version: v8
  • UI Type: MVC
  • Database System: EF Core (SQL Server)
Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

1 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    You can consider using code.

    For example:

    A code : 00001 A.1 code : 00001.00001 A.2 code : 00001.00002 A.1.1 code 00001.00001.00001 B code 00002 B.1 code 00002.00001

    You can easily query all children through code.

    Here is a open source project you can check this: https://github.com/maliming/Owl.GeneralTree

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 23, 2026, 09:57
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.