Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Different fields on two databound objects

    Hi,

    I have two databound objects - ListGrid and DynamicForm. What I want to do is to be able to have different fields on those two objects as well as add additional ones.

    For example, if you consider a typical user account table with the following fields:

    id {pk}
    username
    password
    lastlogin
    status
    privilege

    When I data bind the source to ListGrid and DynamicForm, I get all of the above fields displayed except id (which is .setHidden(true)). But I do want it arranged as follows:

    ListGrid:

    username
    lastlogin
    status
    privilege

    DynamicForm:

    username
    password
    confirmpassword (non-db)
    lastlogin
    status
    privilege

    I don't understand how I can pick and mix which fields to display in a databound object. I tried .setFields option but that seems to only be for non-databound fields.

    I have also tried the following:

    Code:
    final DataSource userDataSource = new VDataSource("app/user/");
    
    DataSourceField uField = new DataSourceField("username", FieldType.TEXT,"Username");
    userDataSource.addField(uField);
    		
    TextItem uTextField = new TextItem();
    uTextField.setTitle("Username");
    uTextField.setDisplayField("username");
    
    final DynamicForm form = new DynamicForm();
    
    //form.setDataSource(userDataSource);
    form.setFields(uTextField);
    This kind of worked, however, when I tried to do form.saveData(), I got an error message saying that .saveData() is not support for non-databound DynamicForm.

    Any ideas?

    P.S. I am quite new in Java/GWT, so be gentle :)

    #2
    If you want to change orders of fields, use .setFields(). See the examples. You can choose any order and apply additional client-side handling as desired. When the ID/name of a field matches one in the datasource your settings supplement those from the datasource. See the DataBoundComponent in the reference docs.

    Comment

    Working...
    X