Notice
		                                        
										
                                    
                                        
                                    
                                        Recent Posts
                                        
                                    
                                        
                                    
                                        Recent Comments
                                        
                                    
                                        
                                    
                                        Link
                                        
                                    
                                | 일 | 월 | 화 | 수 | 목 | 금 | 토 | 
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 | 
| 9 | 10 | 11 | 12 | 13 | 14 | 15 | 
| 16 | 17 | 18 | 19 | 20 | 21 | 22 | 
| 23 | 24 | 25 | 26 | 27 | 28 | 29 | 
| 30 | 
                                        Tags
                                        
                                    
                                        
                                    - R
 - Android
 - es6
 - Java
 - SQL
 - SPC
 - SSL
 - react
 - 공정능력
 - Eclipse
 - 보조정렬
 - Spring
 - xPlatform
 - plugin
 - vaadin
 - mapreduce
 - JavaScript
 - Sqoop
 - hadoop
 - Express
 - Python
 - window
 - tomcat
 - IntelliJ
 - MSSQL
 - NPM
 - table
 - mybatis
 - GIT
 - Kotlin
 
                                        Archives
                                        
                                    
                                        
                                    - Today
 
- Total
 
DBILITY
vaadin table/grid Image display 본문
반응형
    
    
    
  VO class에 String으로 저장된 Image file명으로 Table/Grid에 Image를 출력하고자 할 경우
CellStyleGenerator를 구현하면 된다.
Grid의 경우 추가적으로 Renderer를 설정해야 하며,
다음은 코드 일부다
grid.getColumn("image").setRenderer(new ImageRenderer(),new Converter<ThemeResource, String>(){
	@Override
	public String convertToModel(ThemeResource value, Class<? extends String> targetType, Locale locale)
			throws ConversionException {
		logger.debug("{}", value.getResourceId());
		return null;
	}
	@Override
	public ThemeResource convertToPresentation(String value, Class<? extends ThemeResource> targetType, Locale locale)
			throws ConversionException {
		if(value==null)
			return null;
		else
			return new ThemeResource("img/"+value);
	}
	@Override
	public Class<String> getModelType() {
		return String.class;
	}
	@Override
	public Class<ThemeResource> getPresentationType() {
		return ThemeResource.class;
	}
});
//grid.setStyleName("v-round-image-grid");
grid.setCellStyleGenerator(new Grid.CellStyleGenerator() {
	@Override
	public String getStyle(CellReference cell) {
		if(cell.getPropertyId() != null && cell.getPropertyId().toString().equals("image")) {
			return "imagecol";
		}
		return null;
	}
});
grid column에 적용될 css
 .imagecol {
 	padding : 5px 0 0 0;
 	vertical-align:bottom;
 }
 .imagecol img {
 	width: 25px;
 	height: 25px;
 	border-radius: 29px;
 	box-shadow: 0 2px 3px rgba(0, 0, 0, 0.05);
 	display: block;
 	vertical-align:middle;
 	margin: 0 auto 0.3em;
 	border: 1px solid #c5c5c5;
 }
반응형
    
    
    
  'front-end & ui > vaadin legacy' 카테고리의 다른 글
| vaadin 8 icon 설정 (0) | 2018.07.09 | 
|---|---|
| vaadin table header text alignment (0) | 2018.07.06 | 
| vaadin table/grid Date format display (0) | 2018.07.02 | 
| vaadin file upload (0) | 2018.06.28 | 
| vaadin Sub-Window 사용하기 (0) | 2018.06.28 | 
                          Comments
                        
                    
                
            
                
            
				
				
				
				
                
							