0

Create Grid Columns in Java ONLY

asked 2013-04-12 20:03:25 +0800

ansancle gravatar image ansancle
317 9

I create grids dynamically everywhere, I create the columns,rows, etc.. all on the fly in Java. However, the grid itself is always defined in the .zul file which allows me to specify that it has columns :

<dhUserGrid id="_userGrid"  width="300px">
    <columns>           
    <column/>
   </columns>
</dhUserGrid>

I now want to create the grid 100% in java and then just set it's parent also in the java :

So the zul would have no entry except for the parent :

 <groupbox id="_gridParent"/>

The java would have :

DHeUserGrid _userGrid = new DHeUserGrid();
_userGrid.setParent(gridParent);

When I do this, my code that creates the columns for the grid throws an exception since the Columns are null when the grid.getColumns() is called. There is no method to set the columns, how can I do this without having to specify the grid in the zul file with columns???

private void buildColumns()
{
    // !!!! getColumns RETURNS NULL !!!!!
    _grid.getColumns().getChildren().clear();
    int i = 0;
    if (_bShowLabels == true)
    {
        Column newColumn = new Column();
        newColumn.setAlign("center");   
        newColumn.setWidth(_labelColumnWidth);
        _grid.getColumns().appendChild(newColumn);  
        i++;
    }
    while (i <=_maxColumns)
    {
        Column newColumn = new Column();
        newColumn.setAlign("center");   
        if (i != 0)
            newColumn.setWidth(_buttonColumnWidth);
        else
            newColumn.setWidth(_buttonColumnWidth);
        _grid.getColumns().appendChild(newColumn);          
        i++;
    }   
}
delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
3

answered 2013-04-12 23:02:05 +0800

gganassin gravatar image gganassin flag of Luxembourg
540 6
http://www.hybris.com/

new Columns().setParent(grid);

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2013-04-12 20:03:25 +0800

Seen: 65 times

Last updated: Apr 12 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More