Announcement

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

    Issue with setAutoFitFieldWidths for ListGrid without data

    Hello Isomorphic,

    please help me regarding following bug found in new autofit features:

    GWT 2.1.1, SmartGWT 2.4 LGPL
    GWT development mode
    Windows 7, Firefox 3.6.3, IE 8.0

    Code:
                ListGridField fieldFirst = new ListGridField("first", "First");
                ListGridField fieldLast = new ListGridField("last", "Last");
                ListGridField fieldProfession = new ListGridField("profession", "Profesion");
    
                ListGrid listGrid = new ListGrid();
                listGrid.setWidth(200);
                listGrid.setAutoFetchData(true);
                listGrid.setAutoFitData(Autofit.VERTICAL);
                listGrid.setSelectionType(SelectionStyle.SINGLE);
                listGrid.setCanSort(false);
                listGrid.setCanMultiSort(false);
                listGrid.setCanReorderFields(false);
                listGrid.setCanPickFields(false);
                listGrid.setCanFreezeFields(false);
                listGrid.setCanGroupBy(false);
                listGrid.setShowEmptyMessage(false);
                listGrid.setLeaveScrollbarGap(false);
                listGrid.setCanResizeFields(false);
                listGrid.setCanAutoFitFields(false);
                listGrid.setAlternateRecordStyles(true);
    
                listGrid.setAutoFitFieldWidths(true);
                listGrid.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
                listGrid.setAutoFitFieldsFillViewport(true);
                listGrid.setAutoFitExpandField("lastName");
                listGrid.setAutoFitClipFields("profession");
    
                listGrid.setFields(fieldFirst, fieldLast, fieldProfession);
    
                listGrid.draw();
    I expected the three fields to be fitted into the width of the ListGrid also if there is no record present in the grid. AutoFitWidthApproach.BOTH should then be using the title only. Instead, only fields fieldFirst and fieldLast are shown in the ListGrid both rendered in 100px width (see also attached screenshot). Changing the amount of fields and width of the ListGrid implies that in this case fields are always rendered using width 100px instead title width. Removing the setCan... calls produces even more strange result including horizontal scrollbar. Adding setUseAllRecords and setUseAllColumns does not have any effect on the result. Please can you help me or advice a workaround?

    Thanks a lot!
    ~limubai
    Attached Files

    #2
    You've enabled autofitting to data. The grid is waiting for data before it will autofit.

    Comment


      #3
      Not sure what you want to say. Using AutoFitWidthApproach.BOTH means title and data should be considered for rendering the width. AutoFitWidthApproach.TITLE produces the same result as in the screenshot which is strange as well as then missing records should not matter. AutoFitWidthApproach.VALUE works, also without records as expected, but when data is shorter than title the latter is clipped which I dont like here. Waiting for a good idea or fix...thanks!

      Comment


        #4
        There's nothing to fix. This grid has no data and it's waiting to autoFit to the larger of data and title. It will not autoFit to either until it has data.

        Comment


          #5
          Ok.I understand your reasoning. But for a user who is used to 3 columns and does see only 2 columns because the grid is empty this might be strange. My suggestion is to calculate the width based on title only in case of TITLE. Based on title only in case of BOTH and no data and as soon as data is shown based on title and value. In case of VALUE width should be rendered based on value and if there is no data based on title. The latter works already correct. I think other developers will face the same issue and its no big adjustment, just some lines of code in the width calculation algorithm. Thanks.

          Comment


            #6
            This would involve two autofit runs every time for BOTH mode, and this is expensive, so no, we won't be making that change.

            Comment

            Working...
            X