Announcement

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

    Images in grid are not displayed

    Hello!
    I hope someona can tell me what am I doing wrong. I want to create a grid table with a column where I display an Image. If I click on this image an action is performed. I get the data for this grid by a GWT RPC call.
    However the images are not displayed in the grid.

    This is the code of the grid:
    Code:
    ListGridField diagnosisId = new ListGridField("diagnosisId", "ID", 20);
    		ListGridField diagnosisName = new ListGridField("diagnosis", lang.assumedDiagnosis(), 150);
    		ListGridField action = new ListGridField("action", lang2.action(),100);
    		action.setType(ListGridFieldType.IMAGE);
    		
    		
    		list.setWidth(280);
    	    list.setHeight100();
    	    list.setShowAllRecords(true);
    	    list.setWrapCells(true);
    	    list.setFields(diagnosisId, diagnosisName, action);
    	    list.addDoubleClickHandler(new DoubleClickHandler() {
    
    			@Override
    			public void onDoubleClick(DoubleClickEvent event) {
    				System.out.println(list.getSelectedRecord().getAttribute("diagnosisId"));
    				
    				DiagnosisStackSummary stack = new DiagnosisStackSummary(Integer.parseInt(list.getSelectedRecord().getAttribute("diagnosisId")), 500, 400);
    				SmartGwtWindow window = new SmartGwtWindow();
    				window.createSmartGwtWindow(520, 450, list.getSelectedRecord().getAttribute("diagnosis"), stack.createDiagnosisStackSummary(), false);
    				
    			}});
    	    
    	    service.getDiagnosis(sessionPID, new AsyncCallback<List<ClientDmisSessionDiagnosis>>() {
    
    			@Override
    			public void onFailure(Throwable caught) {
    				Window.alert("Error: "+caught.getMessage());
    			}
    
    			@Override
    			public void onSuccess(List<ClientDmisSessionDiagnosis> result) {
    				data = new DiagnosisGridListData[result.size()];
    				System.out.println("Creating Diagnosis list...");
    				for(int i = 0; i<result.size(); i++){
    					System.out.println("Diagnosis name: "+result.get(i).getRecord().getName());
    					Img deleteIcon = new Img("../components/images/delete16.png");
    					deleteIcon.setLayoutAlign(Alignment.CENTER);
    					deleteIcon.setTitle("Delete");
    					
    					final int tempId = result.get(i).getPID();
    					deleteIcon.addClickHandler(new ClickHandler(){
    
    						@Override
    						public void onClick(ClickEvent event) {
    							Window.alert("Trashing diagnosis with ID: "+tempId);
    							
    						}});
    					data[i] = new DiagnosisGridListData(result.get(i).getPID(), result.get(i).getRecord().getName(), deleteIcon);
    					list.setData(data);
    				}
    				
    			}
    	    	
    	    });
    	    
    	    return list;
    And this is by data class:

    Code:
    public class DiagnosisGridListData extends ListGridRecord {
    	
    	public DiagnosisGridListData(int diagnosisId, String diagnosis, Img img){
    		setDiagnosisId(diagnosisId);
    		setDaignosis(diagnosis);
    		setAction(img);
    	}
    
    	private void setAction(Img img) {
    		setAttribute("action",img);
    	}
    
    	private void setDaignosis(String diagnosis) {
    		setAttribute("diagnosis",diagnosis);
    	}
    
    	private void setDiagnosisId(int diagnosisId) {
    		setAttribute("diagnosisId", diagnosisId);
    		
    	}
    }
    Thank you really for your help!!!!!!!!
Working...
X