Announcement

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

    field.editorProperties.width(*) ignored in FilterBuilder

    Hi,
    This is the test case in which FilterBuilder is bounded to the DataSource. DataSource field 'employer' has editorProperties set; among them width is set to fill available space '*':
    Code:
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.data.DataSourceField;
    import com.smartgwt.client.data.OperationBinding;
    import com.smartgwt.client.data.fields.DataSourceTextField;
    import com.smartgwt.client.types.AutoFitWidthApproach;
    import com.smartgwt.client.types.DSDataFormat;
    import com.smartgwt.client.types.DSOperationType;
    import com.smartgwt.client.types.DSProtocol;
    import com.smartgwt.client.widgets.form.FilterBuilder;
    import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    
    public class MainEntryPoint implements EntryPoint {
       
        public void onModuleLoad() {
    
            layout();
        }
       
        private void layout() {
    
            DataSource employmentDS = new DataSource();
            employmentDS.setID("Employment");
            OperationBinding fetchBinding = new OperationBinding();
            fetchBinding.setOperationType(DSOperationType.FETCH);
            fetchBinding.setDataFormat(DSDataFormat.XML);
            fetchBinding.setDataProtocol(DSProtocol.POSTXML);
            employmentDS.setOperationBindings(fetchBinding);
            employmentDS.setDataURL("Employment.xml");
           
            DataSource departmentDS = new DataSource();
            departmentDS.setID("Department");
            departmentDS.setOperationBindings(fetchBinding);
            departmentDS.setDataURL("Department.xml");
           
            DataSourceField idDepField = new DataSourceField();
            idDepField.setName("id");
            idDepField.setPrimaryKey(true);
            idDepField.setHidden(true);
            DataSourceTextField codeField = new DataSourceTextField();
            codeField.setName("code");
            departmentDS.setFields(idDepField, codeField);
    
            DataSourceField idField = new DataSourceField();
            idField.setName("id");
            idField.setPrimaryKey(true);
            idField.setHidden(true);
            DataSourceField employerField = new DataSourceField();
            employerField.setName("employer");
            employerField.setForeignKey("Department.id");
            employerField.setValueXPath("employer/id");
            ComboBoxItem defaultItem = new ComboBoxItem("employer");
            defaultItem.setOptionDataSource(departmentDS);
            defaultItem.setValueField("id");
            defaultItem.setDisplayField("code");
            defaultItem.setWidth("*");
            defaultItem.setPickListFields(new ListGridField("id", "A very long iddddddddddddddddd title"), new ListGridField("code", "A very longggggggggggggggggggggggggg code title"));
            ListGrid pickListProperties = new ListGrid();
            pickListProperties.setAutoFitFieldWidths(true);
            pickListProperties.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
    //        pickListProperties.setCanResizeFields(true);
            defaultItem.setPickListProperties(pickListProperties);
            employerField.setEditorProperties(defaultItem);
            DataSourceTextField descriptionField = new DataSourceTextField();
            descriptionField.setName("description");
            employmentDS.setFields(idField, employerField, descriptionField);
    
            FilterBuilder fb = new FilterBuilder();
            fb.setDataSource(employmentDS);
            fb.setWidth100();
            fb.draw();
            
        }
       
    }
    Above code is working fine as shown here: code field (which is first on the list and drawn initially), fills all available width allowing pickList to adjust to the titles width.
    Click image for larger version

Name:	fb_field_width0.png
Views:	121
Size:	16.3 KB
ID:	239078Now change the line:
    Code:
    employmentDS.setFields(idField, employerField, descriptionField);
    to:
    Code:
    employmentDS.setFields(idField, descriptionField, employerField);
    so the description field is initially first and run again.
    Click image for larger version

Name:	fb_field_width1.png
Views:	67
Size:	10.0 KB
ID:	239079
    and choose Employer field:
    Click image for larger version

Name:	fb_field_width2.png
Views:	84
Size:	15.0 KB
ID:	239080
    This time width of employer field is not extended to fill form space and pickList is also narrowed and ignoring adjusting to titles.
    Thanks,
    MichalG
    SmartClient Version: v11.0p_2016-07-07/LGPL Development Only (built 2016-07-07)
    FF 24.8.0 and Chrominium 38.0.2125.101
    Data xml files:
    Employment.xml
    Code:
    <response>
        <status>STATUS_SUCCESS</status>
        <startRow>0</startRow>
        <endRow>1</endRow>
        <totalRows>2</totalRows>
        <data>
            <Employment>
                <id>20</id>
                <employer>
                    <id>3</id>
                    <code>Microsoft</code>
                </employer>
            </Employment>
            <Employment>
                <id>21</id>
                <employer>
                    <id>4</id>
                    <code>Apple</code>
                </employer>
            </Employment>
        </data>
    </response>
    Department.xml
    Code:
    <response>
        <status>STATUS_SUCCESS</status>
        <startRow>0</startRow>
        <endRow>4</endRow>
        <totalRows>5</totalRows>
        <data>
            <Department>
                <id>1</id>
                <code>Oracle</code>
                <parentId>
                    <id>2</id>
                    <code>Sun</code>
                </parentId>
            </Department>
            <Department>
                <id>2</id>
                <code>Sun</code>
                <parentId>
                    <id>2</id>
                    <code>Sun</code>
                </parentId>
            </Department>
            <Department>
                <id>3</id>
                <code>Microsoft</code>
                <parentId>
                    <id>2</id>
                    <code>Sun</code>
                </parentId>
            </Department>
            <Department>
                <id>4</id>
                <code>Apple</code>
                <parentId>
                    <id>2</id>
                    <code>Sun</code>
                </parentId>
            </Department>
        </data>
    </response>

    #2
    Seems to be fixed in SmartClient Version: v11.0p_2016-07-14/LGPL Development Only (built 2016-07-14).
    Thank you.
    MichalG

    Comment


      #3
      Yes, we made a fix to have DSField.editorProperties.width properly enforced over filterBuilder.valueItemWidth.

      Comment

      Working...
      X