Results 1 to 7 of 7

Thread: GWT: How to hide columns in List View?

  1. #1

    Question GWT: How to hide columns in List View?

    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

  2. #2
    Join Date
    Oct 2010
    Location
    Guernsey
    Posts
    18

    Default

    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
    }

  3. #3

    Default

    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

  4. #4
    Join Date
    Oct 2010
    Location
    Guernsey
    Posts
    18

    Default

    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.

  5. #5

    Default

    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.

  6. #6
    Join Date
    Oct 2010
    Location
    Guernsey
    Posts
    18

    Default

    No, there doesn't appear to be a straightforward way to get a column from a header value.

  7. #7
    Join Date
    Oct 2010
    Location
    Guernsey
    Posts
    18

    Default

    Try adding this routine to your view...

    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;
    }
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •