1) Test
a) test1
b) test2
b.1) Hello
b.2) Ram
2) Test Data
a) Demo
b) dummy
b.1) Cup
b.2) Plate
3) Dummy
a) test11
b) test22
b.1) Hello
b.2) Ram1
If we search text "Hello" then data should looks like below
1) Test
b) test2
b.1) Hello
3) Dummy
b) test22
b.1) Hello

Sam HobbsPosted Nov 20, 2023, 9:59 PM
Search for articles about self-referencing tables and hierarchical tables. Those are two names of the same thing, there are other names that are sometimes used but I forget the others. The articles will explain how to arrange the data such that each item has a reference to the parent.
You also want an index on the text, such as Hello in your example. Then to do the search you describe, search for items with the text and for each result, just walk up the hierarchy and then show the hierarchy from the top down. No need to do the search yourself and walk every existing hierarchy.
Chris LovePosted Nov 20, 2023, 8:10 PM
Hello,
To implement a hierarchical search in a DataTable within an ASP.NET Core application, you could leverage the concept of filtering based on a tree traversal algorithm. Since you're looking to filter the structure and retain the hierarchy, you might consider creating a recursive method that traverses the hierarchy and selectively includes nodes that match the search term.
Here's a high-level example of how you could implement this in C#:
This recursive function will return a new
Nodecontaining only the hierarchy that includes the search term "Hello". You will need to build your tree structure using theNodeclass.The filtering logic is handled within the
Searchmethod, which checks the current node and recursively its children for the search term. Child nodes are only included in the result if they or their descendants match the search term.I hope this helps! Let me know if you have further questions or if you need assistance with a specific part of the implementation.
Nimish SaxenaPosted Nov 20, 2023, 9:10 AM
If I seach "Probation" text then data should be show like Criminal Record->Case Name->Disposition Records->Probation.
i am usng datatable.js
Vishal JoshiPosted Nov 20, 2023, 8:42 AM
To search a hierarchical DataTable recursively, you can:
You can also apply searching to a specific column in DataTables through the column().search() method.
Please share DB and code details to get clear idea of expected solution.