Announcement

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

    setEditorType on data source field declaration and StaticTextItem

    Hi,
    I'm setting the editor type on the data source field declaration, setting a SelectItem widget for every foreign key field (only to let the filter builder use a drop-down list for that field): the problem is that I need to "override" that property even when I use the same field in a read-only way (i.e. as a StaticTextItem) on a form.

    Is there a better way to "inform" the filter builder to use a SelectItem for my foreign keys?


    Here is the data source declaration
    Code:
    final DataSourceIntegerField optionField = new DataSourceIntegerField ("option", "OPTION");
    //NEEDED to let the filter builder show a drop-down list
    final SelectItem optionsItem = new SelectItem ();
    optionsItem.setName (optionField.getName ());
    optionsItem.setOptionDataSource (getOptionDataSource ());
    optionsItem.setValueField ("id");
    optionsItem.setDisplayField ("name");
    optionField.setEditorType (optionsItem);
    
    mainDataSource.addField (optionField);
    and this the StatisTextItem declaration
    Code:
    final StaticTextItem optionItem = new StaticTextItem ("option");
    optionItem.setWrap (false);
    //NEEDED to show the display value on the form (duplicates the data source declaration)
    optionItem.setOptionDataSource (getOptionDataSource ());
    optionItem.setValueField ("id");
    optionItem.setDisplayField ("name");
    //NEEDED to show the display value on the form WITHOUT a drop-down list
    //the screenshot was taken without the following row
    optionItem.setEditorType (new StaticTextItem ());
    I'm also attaching a complete test case.

    At client side I'm using
    SmartClient Version: SC_SNAPSHOT-2010-10-19/LGPL Development Only (built 2010-10-19)
    GWT 2.0.4
    Firefox 3.6.10

    at server side Grails 1.3.4

    Kind regards
    Davide
    Attached Files
Working...
X