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:
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:
Am I misunderstanding something?
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 "; } }); 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");
Comment