Announcement

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

    Custom colum content jumping to the end of the ListGrid when editing or deleting rows

    Custom column content jumping to the end of the ListGrid when editing or deleting rows.

    See attached screenshots, I think this is internal unless I'm adding those buttons some how incorrectly
    Screenshot Bug#1 shows how it is before Delete (red button)
    Screenshot Bug#2 shows how it is after record deleted...

    Red is background color of HLayout containing buttons.

    Please Advice!!

    PS Original column data is under red HLayout, it is not substituting columns, it covering one by another.

    Here is my piece of code:

    Code:
    		final ListGrid listGrid = new ListGrid() {
    			
                 @Override  
                 protected Canvas createRecordComponent(final ListGridRecord record, final Integer colNum) {  
       
                     String fieldName = this.getFieldName(colNum);
                     
                     final ListGrid ref = this;
                      
                     final int rowNum = ref.getRecordIndex(record);
                     
                     if (fieldName.equals("icons")) {  
                         HLayout recordCanvas = new HLayout(3);  
                         recordCanvas.setHeight(22);
                         recordCanvas.setBackgroundColor("red");
                         recordCanvas.setAlign(Alignment.CENTER);  
                         ImgButton mapImg = new ImgButton();  
                         mapImg.setShowDown(false);  
                         mapImg.setShowRollOver(false);  
                         mapImg.setLayoutAlign(Alignment.CENTER);  
                         mapImg.setSrc("iMap.png");  
                         mapImg.setPrompt("View Map");
                         mapImg.setHeight(16);  
                         mapImg.setWidth(16);  
                         mapImg.addClickHandler(new ClickHandler() {  
                             public void onClick(ClickEvent event) {
     							String LATITUDE = record.getAttribute("LATITUDE");
    							String LOGITUDE = record.getAttribute("LOGITUDE");
    							if (LATITUDE != null && LOGITUDE != null) {
    								Window ww = new MapView(LATITUDE, LOGITUDE, record.getAttribute("PDA_ID"));
    								ww.show();
    							} 
                             }
                         });
       
                         ImgButton editImg = new ImgButton();  
                         editImg.setShowDown(false);  
                         editImg.setShowRollOver(false);  
                         editImg.setAlign(Alignment.CENTER);  
                         editImg.setSrc("iEdit.png");  
                         editImg.setPrompt("Edit Record"); 
                         editImg.setHeight(16);  
                         editImg.setWidth(16);  
                         editImg.addClickHandler(new ClickHandler() {  
                        	 public void onClick(ClickEvent event) {  
                            	 ref.startEditing(rowNum, colNum,false);
                             }  
                         });
                         
                         ImgButton deleteImg = new ImgButton();  
                         deleteImg.setShowDown(false);  
                         deleteImg.setShowRollOver(false);  
                         deleteImg.setAlign(Alignment.CENTER);  
                         deleteImg.setSrc("iDelete.png");  
                         deleteImg.setPrompt("Delete Record");
                         deleteImg.setHeight(16);  
                         deleteImg.setWidth(16);  
                         deleteImg.addClickHandler(new ClickHandler() {  
                             public void onClick(ClickEvent event) {
                             	if(com.google.gwt.user.client.Window.confirm("Are you sure?"))
                             		ref.removeData(record);
                              }
                        });
    
                        recordCanvas.addMember(editImg);   
                        recordCanvas.addMember(deleteImg);
                        if(ref.getDataSource().getTableName().equals("PDA"))
                        	recordCanvas.addMember(mapImg);
    
                         return recordCanvas;  
                     } else {  
                         return null;  
                     }  
                 }  
    		};
    
    		listGrid.setHeight100();
    		listGrid.setWidth100();
    		listGrid.setAutoFetchData(true);
    		listGrid.setShowFilterEditor(true);
    		listGrid.setCanEdit(true);
    		listGrid.setShowRecordComponents(true);        
    		listGrid.setShowRecordComponentsByCell(true);
    		listGrid.setAlternateRecordStyles(true);
    		listGrid.setShowAllRecords(true);
    
    		listGrid.setUseAllDataSourceFields(true);		
    
    		ListGridField listFieldIcons = new ListGridField();
    		listFieldIcons.setType(ListGridFieldType.ICON);
    		listFieldIcons.setName("icons");
    		listFieldIcons.setTitle("Action");
    		listFieldIcons.setCanFilter(false);
    		listFieldIcons.setCanEdit(false);
    		listFieldIcons.setWidth(100);
    		listGrid.setFields(listFieldIcons);
    		
    		listGrid.setDataSource(ds);
    Attached Files
    Last edited by ectar; 21 Jul 2010, 08:37.
Working...
X