I have a working GWT/GAE roo-generated app (1.1.3). One of my entities has far too many fields to display in the list view. How do I hide some of the columns?
Dan
I have a working GWT/GAE roo-generated app (1.1.3). One of my entities has far too many fields to display in the list view. How do I hide some of the columns?
Dan
Am not sure if this is the best way but it seems to work:-
public CisxUserListView() {
init(BINDER.createAndBindUi(this), table, newButton);
table.setKeyboardSelectionPolicy(KeyboardSelection Policy.DISABLED);
init();
table.removeColumn(0); // <---Added this line
}
Gary - yes I considered that but it seems so crude and needs to be manually maintained. I don't see any way to get the column number by header value or something that won't break if the order changes.
Does not seem like we can change the order either.
Seems we need an annotation. @RooHideInList
Thanks
Hi Dan,
I agree. the GWT module for Roo could do with annotations to control visibility and position of all entity fields in the list view as well as the other views.
You can move columns round like this but its not very pretty or easily maintained:-
public CisxUserListView()
{
init(BINDER.createAndBindUi(this), table, newButton);
table.setKeyboardSelectionPolicy(KeyboardSelection Policy.DISABLED);
init();
// Move id column from first column of table to last
Column<CisxUserProxy,?> c = table.getColumn(0);
table.removeColumn(c);
table.addColumn(c,"ID");
}
This also lets you change the column heading text.
Gary - thanks for the sample code. Very helpful. I take it you have not been able to get a column based on the Header value rather than by position? I don't see where the value is exposed in the column object.
No, there doesn't appear to be a straightforward way to get a column from a header value.
Try adding this routine to your view...
Note it doesn't work from the view's constructor but seems to work okay once the DOM has been constructed e.g. in the views onLoad() or if run from a button click handler say.Code:private int getIndexFromHeaderText(String str) { int index = -1; Element e1 = table.getElement(); // <table> if(e1!=null) { Element e2 = DOM.getFirstChild(e1); // <thead> if(e2!=null) { Element e3 = DOM.getFirstChild(e2); // <tr> if(e3!=null) { for(int col=0; col<e3.getChildCount(); col++) { Element e4 = DOM.getChild(e3,col); // <th> if (str.equals(DOM.getInnerHTML(e4))) { index=col; break; } } } } } return index; }