My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 196: Contribution: set column properties easily
1 person starred this issue and may be notified of changes. Back to list
Status:  WontFix
Owner:  ----
Closed:  Jun 2009


 
Reported by AlejaV...@gmail.com, May 14, 2009
Here is another little contribution that I use very often (in all my
tables). And it shows also another little problem that I found when
exporting my tables.
It is a method to set the params of a column (title, filterable, sortable,
editable) in an easy way. I have it in some util class but in case it is
admisible for jmesa it should go, I guess, in the Table or Row
implementations (but look out for the export problem I'll explain at the
end of the post)

This is it:

	public static void setColumnParams(Table table, String property, String
title, boolean filterable, boolean sortable, boolean editable) {
		
		if (table instanceof HtmlTable) {
			HtmlRow htmlRow = ((HtmlTable)table).getRow();
			HtmlColumn htmlColumn = htmlRow.getColumn(property);
			htmlColumn.setTitle(title);
			htmlColumn.setFilterable(new Boolean(filterable));
			htmlColumn.setSortable(new Boolean(sortable));
			htmlColumn.setEditable(new Boolean(editable));
		}
		else if(table instanceof TableImpl){
			Row row =((TableImpl)table).getRow();		
			Column column = row.getColumn(property);
			column.setTitle(title);			
		}

	}

I usually create my methods so they can be used when rendering the html and
when exporting (I like to set the title of the column in both cases or do
strange things with the values as well). This leads to a little problem:
When exporting to EXCEL the table is not an instance of HtmlTable, which is
correct because it is meaningless to render html or to make the column
filterable, sortable, ... when making an Excel. But it's not the case when
exporting to PDF (or while rendering the html, of course).
This makes that if you want to do something with a column that will show up
in both cases (html and export) you have always to check the class type of
the table or you will be facing some "pretty" ClassCastExceptions...

The same way I can set a column with my CheckBoxCellEditor (see the Issue
for that contribution) before the code that makes the export so it can
apply to render html and exporting.
I hope I made myself clear and haven't been too boring... hehe
(and by the way, I'm always sorry if my english is not perfect...)

Cheers,
Alex

May 15, 2009
Project Member #1 jeff.johnston.mn@gmail.com
You know what would be interesting would be to use the builder pattern. The pattern
would works perfect even though it would be to populate the object. Even the renderer
methods could be exposed through the builder. The great thing is how easy it is to
read and work with.

Something like this:

ColumnPopulator populator = new ColumnPopulator(TableFacade tableFacade, String
columnName);
populator.filterable(false).sortable(false).editable(true).cellEditor(myCellEditor);



Labels: -Type-Defect Type-Enhancement
May 19, 2009
#2 danniv21@gmail.com
how can i sum a whole column? 

how can i group columns?    
May 20, 2009
Project Member #3 jeff.johnston.mn@gmail.com
To group and total columns you need to create a custom view. Its a little involved
but not too difficult once you get the hang of it. It is very powerful though and
allows you to tweak the view however you want!

https://code.google.com/p/jmesa/wiki/GroupColumnsTutorial
Jun 11, 2009
Project Member #4 jeff.johnston.mn@gmail.com
(No comment was entered for this change.)
Status: WontFix

Powered by Google Project Hosting