PDA

View Full Version : GridTemplates, private and hidden resource?



jeronimoh
9 Oct 2008, 1:28 AM
Whooow, it took me quite a while to explore how GXT's templates work. I'm trying to implement some specific functionality around a Grid (or more precisely, GridView). For that purpose, I have read much of the standard GridView's source code and I was especially interested in exploring it's HTML rendering techniques. For that purpose, I also studied GXT's templating system. After some digging, I found files like GridTemplates#master.html or GridTemplates#cell.html reside in gxt.jar. It took me a lot of time to realize, that those files reside in that jar but at the same time, they are missing in downloaded source code (gxt-1.1/src/com/.... doesn't contain them and it's my mistake I was trying to find them there). Nevertheless, I will probably have to change some of those HTML template files to achieve desired functionality. I can definitely extract provided jar and perform changes there, but I'm still confused with the fact those templates are missing in source code directory structure. Are they something private or hidden, from the GXT author's point of view? From my point of view, "src/..." directory should contain all (of course only those not compiled yet) parts of gxt.jar, but that's just an opinion.

leonate
9 Oct 2008, 5:24 AM
You can extend GridView and override initTemplates() method to create your custom GridTemplates implementation. In this case you have to provide your own templates.
For example if you create CustomGridTemplates you will need to put following files:
CustomGridTemplates#body.html
CustomGridTemplates#cell.html
and so on.
Basically you can copy the ones from gxt.jar and rename them. Then modify those templates which you need to update.

Still it would be good to have better documentation/samples around this.
Also it would be good to make some private methods of GridView protected.

I did this template overriding to create one more header row to place totals in it.

It would be good to have multi-row header or totals support built-in to GXT. But until this is done we need to hack GXT code in this undocumented way.

--
Regards,
Leo