Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Grouping and UnGrouping of JTable Rows

 
Neelakantan Kuthalanathan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

As anyone done Grouping and UnGrouping of JTable Rows as we find in MS Excel?
Any pointers??
 
Maneesh Godbole
Saloon Keeper
Posts: 11178
15
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Neelakantan Kuthalanathan:
Hi,

As anyone done Grouping and UnGrouping of JTable Rows as we find in MS Excel?
Any pointers??


Check out:
http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#sorting

Similar values will be grouped together after you sort.
 
Neelakantan Kuthalanathan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for teh reply..
But my requirement is different.
I need have a expandable nodes to expand/hide the grouped rows.
To understand my requirement,best example could be to See the Grouping feature in Ms-Excel.

thanks
neel
 
Maneesh Godbole
Saloon Keeper
Posts: 11178
15
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My bad.
Missed out on what your saying completely.

Something like this?
http://java.sun.com/products/jfc/tsc/articles/treetable1/
 
Neelakantan Kuthalanathan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I need a feature like this.....But I am not sure how to change the FileSystemModel in the example to my requirement.

My requirent is like this as I have attached the Screen Shot:


As shown the screenshot i want the Group 1 ,2,3 to be expandable and hideable i.e should behave like a Jtree node.....In rest of the column User can enter any input i.e for the columns A,B,C..

I Hope you understood my problem now.
 
Neelakantan Kuthalanathan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Rob Spoor
Sheriff
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check the link Maneesh has provided. A tree table looks to exactly what you need.
 
Neelakantan Kuthalanathan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks.I tried with the example.
But I have two problems I am facing:

1. The grid lines does'nt extend till the tree node
2. the Horizontal scroll bar never gets added...I am adding the JtreeTable component into scrollpane and set
but still no effect.

I am attaching the screen shot for your reference.


Any idea to resolve the issue
 
Rob Spoor
Sheriff
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Neelakantan Kuthalanathan:
2. the Horizontal scroll bar never gets added...I am adding the JtreeTable component into scrollpane and set
but still no effect.

That's a default property of JTable. Fortunately you can change it, using JTable.setAutoResizeMode. You'll most likely want AUTO_RESIZE_OFF.
 
Neelakantan Kuthalanathan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks.
any idea on how to have the grid lines extended for the Jtree nodes?
 
Rob Spoor
Sheriff
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you need to play around with the tree's cell renderer. Using a LineBorder could do the trick. table.getGridColor() will return the color of the grid lines so they will always be the same.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic