Announcement

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

    Problem autofitting listgrid

    SmartClient Version: v10.0p_2015-01-02/Pro Deployment (built 2015-01-02)

    When my listgrid is first drawn, the autofitting is correct but if I rightclick and select "Auto Fit All Columns" in the context menu the listgrid changes the widths of the columns in the datalines without changing the widths of the headers so they no longer match (see attached pictures)

    The listgrid looks as follows:
    Code:
    ListGridField deadlineField = new ListGridField("deadline");
    deadlineField.setCellFormatter(new CellFormatter() {
    	
    	@Override
    	public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
    		if(record.getAttribute("deadline") == null)
    			return null;
    		
    		DateTimeFormat fmt = DateTimeFormat.getFormat("dd/MM/yy");
    		int diff = record.getAttributeAsInt("diff") != null ? record.getAttributeAsInt("diff") : 0; 
    		
    		
    		String result = fmt.format(record.getAttributeAsDate("deadline"));
    		if(diff < 0)
    			result += " (" + Math.abs(diff) + "d. overdue)";
    		else
    			result += " (" + diff + "d. left)";
    		return result;
    	}
    });
    deadlineField.setAlign(Alignment.LEFT);
    
    ListGridField actName = new ListGridField("name");
    actName.setAutoFitWidthApproach(AutoFitWidthApproach.TITLE);
       
    ListGridField remainingHoursField = new ListGridField("remaining");
    remainingHoursField.setAutoFitWidthApproach(AutoFitWidthApproach.TITLE);
    remainingHoursField.setCellFormatter(new CellFormatter() {
    	
    	@Override
    	public String format(Object value, ListGridRecord record, int rowNum,
    			int colNum) {
    		if(value == null || value.toString().equals(""))
    			return null;
    		else
    			return value + "h&nbsp;&nbsp;&nbsp;&nbsp;";
    	}
    });
    
    Map m = new HashMap<>();
    m.put("projectId", sessionManager.project.getId());
    
    DataSource activityDS = DataSource.get("dashboard_activities");
    activityDS.setDefaultParams(sessionManager.extendParams(m));
    
    final ListGrid activitiesGrid = new ListGrid(){
    	@Override
    	protected String getCellCSSText(ListGridRecord record, int rowNum,
    			int colNum) {
    		if(getFieldName(colNum).equals("deadline"))
    		{
    			if(record.getAttribute("diff") != null && record.getAttributeAsInt("diff") < 0)
    			{
    				return "color:#e83838;";
    			}
    		}
    		return super.getCellCSSText(record, rowNum, colNum);
    	}
    };
    activitiesGrid.setShowSortArrow(SortArrow.FIELD);
    activitiesGrid.setWidth100();
    activitiesGrid.setHeight100();
    activitiesGrid.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
    activitiesGrid.setAutoFitFieldWidths(true);
    activitiesGrid.setAutoFitFieldsFillViewport(true);
    activitiesGrid.setAutoFitExpandField("name");
    activitiesGrid.setSelectionType(SelectionStyle.SINGLE);
    activitiesGrid.setDataSource(activityDS);
    activitiesGrid.setUseAllDataSourceFields(true);
    activitiesGrid.setFields(actName, remainingHoursField, deadlineField);
    activitiesGrid.setAutoFetchData(true);
    activitiesGrid.setEmptyMessage(sessionManager.getText("EMPTY_MSG_PROJECT_ACTIVITIES"));



    2nd question
    The previous problem solves itself when manually changing the width of a column by dragging it with your mouse. But if I press "Auto Fit All Columns" again the grid columns do not expand to fill the viewport even though I set:
    Code:
    activitiesGrid.setAutoFitFieldWidths(true);
    activitiesGrid.setAutoFitFieldsFillViewport(true);
    activitiesGrid.setAutoFitExpandField("name");
    Am I misunderstanding something?
    Attached Files

    #2
    We noticed the same issue today as well.

    SmartClient Version: v9.1p_2014-11-09/Pro Deployment (built 2014-11-09)

    Regards

    Comment


      #3
      Thanks for letting us know - we're taking a look

      Regards
      Isomorphic Software

      Comment


        #4
        We have now made a change which we believe will address this issue.
        Please try the next nightly build, dated Jan 14 or above.
        The change has been applied to SmartClient 9.1p (SGWT 4.1p), SmartClient 10.0p (SGWT 5.0p) and SmartClient 10.1d (SGWT 5.1d)

        Regards
        Isomorphic Software

        Comment


          #5
          Thank you.

          Comment


            #6
            We are still seeing an issue with "Auto Fit" in the following build.

            SmartClient Version: v9.1p_2015-01-27/Pro Deployment (built 2015-01-27)

            Chrome Version 40.0.2214.91 (64-bit)
            Firefox ESR 24.8.1

            Please see the attached screenshot.
            Attached Files

            Comment


              #7
              The screenshot looks like the previously reported bug, which we addressed.
              We'll need a way to reproduce. Can you please either give us steps to reproduce using one of the shipped samples (if the problem occurs there), or show us a sample we can run (an EntryPoint class we can actually drop into an Eclipse project and run without modification would be preferable), along with steps to reproduce the problem.

              Thanks
              Isomorphic Software

              Comment


                #8
                SmartClient Version: v9.1p_2015-01-27/Pro Deployment (built 2015-01-27)

                Run the sample below and use AutoFit option from "Field 1".

                See attached screenshot.

                Code:
                package com.sandbox.client;
                
                import java.util.Date;
                
                import com.google.gwt.core.client.EntryPoint;
                import com.smartgwt.client.data.DataSource;
                import com.smartgwt.client.data.DataSourceField;
                import com.smartgwt.client.types.AutoFitWidthApproach;
                import com.smartgwt.client.types.DSDataFormat;
                import com.smartgwt.client.types.FieldType;
                import com.smartgwt.client.widgets.grid.ListGrid;
                import com.smartgwt.client.widgets.grid.ListGridField;
                import com.smartgwt.client.widgets.grid.ListGridRecord;
                import com.smartgwt.client.widgets.layout.VLayout;
                
                public class Sandbox2 implements EntryPoint {
                    DataSource dataSource;
                    ListGrid grid;
                    ListGridRecord[] data = new ListGridRecord[3];
                
                    @Override
                    public void onModuleLoad() {
                
                        data[0] = new ListGridRecord();
                        data[0].setAttribute("fldId", 1);
                        data[0].setAttribute("fld1", "abc 1");
                        data[0].setAttribute("fld2", 10);
                        data[0].setAttribute("fld3", new Date());
                        data[1] = new ListGridRecord();
                        data[1].setAttribute("fldId", 2);
                        data[1].setAttribute("fld1", "Abc 2");
                        data[1].setAttribute("fld2", 20);
                        data[1].setAttribute("fld3", new Date());
                        data[2] = new ListGridRecord();
                        data[2].setAttribute("fldId", 3);
                        data[2].setAttribute("fld1", "ABC 3");
                        data[2].setAttribute("fld2", 30);
                        data[2].setAttribute("fld3", new Date());
                
                        final VLayout appLayout = new VLayout();
                        appLayout.setWidth100();
                        appLayout.setHeight100();
                
                        buildDataSource();
                        buildGrid();
                
                        appLayout.setMargin(5);
                        appLayout.setMembersMargin(5);
                        appLayout.addMembers(grid);
                        appLayout.draw();
                
                        grid.setData(data);
                    }
                
                    private void buildGrid() {
                        grid = new ListGrid();
                        grid.setWidth100();
                        grid.setHeight100();
                
                        grid.setTitle("Test Grid");
                        grid.setAutoFitFieldsFillViewport(Boolean.TRUE);
                        grid.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
                        grid.setAutoFitFieldWidths(Boolean.TRUE);
                        grid.setAlternateRecordStyles(Boolean.TRUE);
                        grid.setWidth100();
                
                        ListGridField gfld1 = new ListGridField("fld1", "Field 1");
                        ListGridField gfld2 = new ListGridField("fld2", "Field 2");
                        ListGridField gfld3 = new ListGridField("fld3", "Field 3");
                
                        grid.setFields(gfld1, gfld2, gfld3);
                        grid.setDataSource(dataSource);
                    }
                
                    private void buildDataSource() {
                        dataSource = new DataSource();
                        dataSource.setClientOnly(true);
                        dataSource.setDataFormat(DSDataFormat.JSON);
                        DataSourceField fldId = new DataSourceField("fldId", FieldType.INTEGER);
                        fldId.setPrimaryKey(true);
                        DataSourceField fld1 = new DataSourceField("fld1", FieldType.TEXT);
                        DataSourceField fld2 = new DataSourceField("fld2", FieldType.INTEGER);
                        DataSourceField fld3 = new DataSourceField("fld3", FieldType.DATE);
                        dataSource.setFields(fldId, fld1, fld2, fld3);
                    }
                }
                Attached Files

                Comment


                  #9
                  Just a quick follow up to let you know we're taking a look.

                  Regards
                  Isomorphic Software

                  Comment


                    #10
                    Hi Isomorphic,
                    We will be picking up tonight's nightly build to get some other fixes and we were wondering if there were any updates regarding this issue as well.
                    Thanks

                    Comment


                      #11
                      We've actually just put a fix in for this. It won't be in the nightly dated Feb 3 - but will be in the next build (Feb 4)
                      Please try that and let us know if it doesn't resolve the issue for you.

                      Regards
                      Isomorphic Software

                      Comment


                        #12
                        Thank you, the problem appears to be resolved in the latest build.

                        Comment

                        Working...
                        X