Show Column Header on dragging column

最后都变了- 提交于 2019-11-27 09:22:51

My predecessor also thought that using code they copied off the internet was a good idea...fortunately for my company, I don't

I spent about 4 weeks of my spare time digging through the implementation and comparing it with the default BasicTableHeaderUI figuring out how to reinstate...

  • Column ordering, including, limiting the grouped columns to there group
  • Row sorting
  • Various other bits and pieces

This is a incomplete solution, as I've not yet quite got to the point where when you drag a group and have it show all the columns in the group, but that's within the TableUI

Unfortunately, I can't paste the code, it's over the 3000 character limit, but you can grab a copy from here

A bit more complete solution: JBroTable.

It's based on MadProgrammer's answer. It restricts column dragging out of the group too. And brings some extra features:

  • Arbitrary number of rows
  • Natural API for model creation
  • Generic support for other L&Fs (Windows system L&F, GTK, Nimbus etc.)

Sample model creation:

IModelFieldGroup groups[] = new IModelFieldGroup[] {   new ModelFieldGroup( "A", "A" )     .withChild( new ModelField( "B", "B" ) )     .withChild( new ModelField( "C", "C" ).withRowspan( 2 ) ), // Custom rowspan set.   new ModelFieldGroup( "D", "D" )     .withChild( new ModelField( "E", "E" ) )     .withChild( new ModelField( "F", "F" ) ),   new ModelField( "G", "G" ),   new ModelFieldGroup( "H", "H" )     .withChild( new ModelFieldGroup( "I", "I" )                   .withChild( new ModelField( "J", "J" ) ) )     .withChild( new ModelField( "K", "K" ) )     .withChild( new ModelFieldGroup( "L", "L" )                   .withChild( new ModelField( "M", "M" ) )                   .withChild( new ModelField( "N", "N" ) ) ) }; 

Result:

Animated demo (2.5M)

Update:

Added drawing of the whole dragged columns group.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!