Announcement

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

    Different autoFit for different ListGridFieldType

    Hi Isomorphic,
    can you please explain different auto-fitting behaviour when the ListGridField type is set to DATE and to TEXT?

    Modified showcase com.smartgwt.sample.showcase.client.grid.datatypes.GridDataTypesDateSample
    Code:
    final ListGrid countryGrid = new ListGrid();
    countryGrid.setWidth(700);
    countryGrid.setHeight(224);
    countryGrid.setShowAllRecords(true);
    countryGrid.setCanEdit(true);
    countryGrid.setEditEvent(ListGridEditEvent.CLICK);
    countryGrid.setModalEditing(true);
    
    // AutoFit is set
    countryGrid.setAutoFitFieldWidths(true);
    countryGrid.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
    
    ListGridField countryCodeField = new ListGridField("countryCode", "Flag", 50);
    countryCodeField.setAlign(Alignment.CENTER);
    countryCodeField.setType(ListGridFieldType.IMAGE);
    countryCodeField.setImageURLPrefix("flags/16/");
    countryCodeField.setImageURLSuffix(".png");
    countryCodeField.setCanEdit(false);
    ListGridField nameField = new ListGridField("countryName", "Country");
    nameField.setWidth(50);
    
    // We test this field
    ListGridField independenceField = new ListGridField("independence", "Nationhood");
    //independenceField.setType(ListGridFieldType.TEXT);
    independenceField.setType(ListGridFieldType.DATE);
    independenceField.setWidth("*");
    
    countryGrid.setFields(new ListGridField[] {countryCodeField, nameField, independenceField});
    
    canvas.addMember(countryGrid);
    
    // Problem occurs only when we set data after the grid is drawn!
    Button button = new Button("Set data");
    button.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            countryGrid.setData(CountrySampleData.getRecords());
        }
    });
    canvas.addMember(button);
    When independenceField is set to TEXT:

    OnDraw:
    Click image for larger version  Name:	Screen Shot 2018-03-19 at 17.37.11.png Views:	2 Size:	16.7 KB ID:	252346
    OnSetData:
    Click image for larger version  Name:	Screen Shot 2018-03-19 at 17.37.24.png Views:	1 Size:	65.4 KB ID:	252344

    When independenceField is set to DATE:
    OnDraw:
    Click image for larger version  Name:	Screen Shot 2018-03-19 at 17.37.47.png Views:	1 Size:	17.3 KB ID:	252343
    OnSetData:
    Click image for larger version  Name:	Screen Shot 2018-03-19 at 17.37.56.png Views:	1 Size:	65.5 KB ID:	252345

    What should be the correct way for ListGridField of type DATE to honour width "*"? We want it to behave the same as field of type TEXT.

    Thanks
    Matus

    Tested on:
    SmartClient Version: v10.0p_2018-03-14/LGPL Development Only (built 2018-03-14)
    GC Version 65.0.3325.162 (Official Build) (64-bit)
    Attached Files
    Last edited by matus_b; 19 Mar 2018, 08:57. Reason: edit picture sizes

    #2
    Since date values in a grid are generally rendered all the same size, we skip auto fitting on such fields for performance reasons. This is all covered in the docs - see autoFitDateFields, getDefaultFieldWidth(), etc.

    Comment


      #3
      Ok, I missed that docs.
      We achieved the grid without empty space with:

      Code:
      countryGrid.setAutoFitFieldsFillViewport(true);
      countryGrid.setAutoFitExpandField("independence");

      Comment

      Working...
      X