0

I have a table with four columns say A B C D. I am using TableViewer to show the results in a table with corresponding headers. Now, I realize that column C is having duplicate values. So I would like to convert this table to a tree using TreeViewer where C will be the parent column and all other rows will be grouped based on that. I have changed the content provider to TreeStructureContentProvider.INSTANCE and also used corresponding TreeViewer classes everywhere. But issue is I can still see the UI in table view only.

Data is somewhat like below:

Table view

-----------------
|A | B | C | D  |
-----------------
|a1  b1  c1  d1 |
-----------------
|a2  b2  c1  d2 |
------------------
|a3  b3  c1  d3 |
------------------
|a4  b4  c2  d4 |
-----------------

Required Tree view

---------------
c1
----
   a1 b1 d1
-------------
   a2 b2 d2
-------------
   a3 b3 d3
---------------
c2
---
   a4 b4 c4
----------------

How to make C as parent and group other rows accordingly?

greg-449
  • 109,219
  • 232
  • 102
  • 145
schaturv
  • 122
  • 8
  • What is `TreeStructureContentProvider`? Your tree content provider has to return the top level elements in the `getElements` method and the appropriate children in the `getChildren` method. – greg-449 Jul 07 '20 at 06:52
  • @greg-449 I am creating the TreeViewer like this TreeViewer treeViewer = new TreeViewer(container, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | border); treeViewer.setContentProvider(TreeStructureContentProvider.INSTANCE); and data is populated during runtime. – schaturv Jul 07 '20 at 06:56
  • But what does `TreeStructureContentProvider` do? It is up to the code in the content provider to arrange the structure you want. – greg-449 Jul 07 '20 at 07:02

0 Answers0