Skip to content
Qualtagh edited this page Jul 11, 2020 · 3 revisions

This is an overview of useful model properties.

Let's take our quick start example and add some tweaks to it.

We'll need a slightly more complex model to show the rowspan property in action:

IModelFieldGroup groups[] = new IModelFieldGroup[] {
  new ModelFieldGroup( "USER", "User" )
    .withChild( new ModelField( "USER_ID", "Identifier" ) )
    .withChild( new ModelFieldGroup( "NAME", "Person name" )
                  .withChild( new ModelField( "FIRST_NAME", "First name" )
                                .withDefaultWidth( 100 ) )
                  .withChild( new ModelField( "LAST_NAME", "Last name" )
                                .withDefaultWidth( 100 ) ) )
    .withChild( new ModelField( "PHONE", "Phone number" )
                  .withDefaultWidth( 200 ) ),
  new ModelFieldGroup( "ORDER", "Order" )
    .withChild( new ModelField( "PRODUCT", "Product" ) )
    .withChild( new ModelField( "QUANTITY", "Quantity" ) )
};

Here is the third level of cells added to the header. Note a property called defaultWidth. User is able to resize columns. And this property sets the initial width of these columns.

Result without rowspan

Take a look at the last columns group. The group caption takes two rows while column captions take one. If the desired behavior is inverse (i. e., group should take one row and columns should take two) then a rowspan property should be used.

new ModelFieldGroup( "ORDER", "Order" )
  .withChild( new ModelField( "PRODUCT", "Product" )
                .withRowspan( 2 ) )
  .withChild( new ModelField( "QUANTITY", "Quantity" ) )

Here is the result we get with the rowspan property set:

Result with rowspan

Property visible set to false hides a field. It's useful if you need to have fields like ROWID which are needed at the model level (e. g., to uniquely identify the row selected) but should be invisible to user. Another scenario is giving the user an ability to manage columns visibility. Then a model would remain unchanged but the view would represent user actions.

To hide a column group, set visible property of all its children to false.

Property manageable set to false denies dragging the column. Also, this column would split the header into two parts: left and right. User won't be able to move columns from the left part to the right one and vice versa.

Full source code.