0

I'm a little bit stucked right now and I hope someone can help me with my problem.

I'm getting a ResultSet from a SQL Query and I want to use GWT CellTable for displaying the content of my ResultSet dynamically based on the ResultSet. I need this for displaying the whole content of an mySQL-Table and I want to make this dynamically so I can create any table and the CellTable will be generated dynamicaly.

Has someone an idea for an convenient way?

Radim Köhler
  • 122,561
  • 47
  • 239
  • 335
spcial
  • 1,529
  • 18
  • 40
  • How are you doing it now? StackOverflow is for assistance with specific programming questions. Your question is too broad to be answered easily. – Simon MᶜKenzie Jun 17 '13 at 04:54
  • I did it statically. I have created a class (for example 'User'), created serveral users with the information given in my table and used these classes to fill my CellTable. But now I'm looking for an more convenient way which helps me to fill a table with any table from my SQLServer without the declaration of a class. – spcial Jun 17 '13 at 05:05

1 Answers1

0

I wouldn't recommend this approach as the drawbacks cleary outweigh the benefits.

Here is the simplest approach I can think of and it only works with one type of column (Text column):

You have to send your data, that you want to display in a generic dynamic CellTable, as a List of Map objects.
When you receiver the data on the client you have to dynamically construct the columns in the CellTable. You can do this by looking at the keys of the first Map object in your List.

You probably will have to implement a custom Column to which you pass the key of the corresponding field in your Map object. In the getValue() method of your custom Column you will return the corresponding field of your Map objects using the key you passed in.
You can then use a TextCell to render the method.

Of course if you want to support different kind of types (Number, Date, etc) it get's more complicated.

Ümit
  • 17,379
  • 7
  • 55
  • 74