Announcement

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

    ListGrid setCanExpandRecord issue

    If using a ListGrid and if I set

    listGrid.setShowRollOverCanvas(true);
    listGrid.setCanExpandRecords(true);

    once the record is expanded, the grid.collapseRecord(record) does not collapse the record.
    if I removed the setShowRollOverCanvas(true) then it works fine.

    any ideas?

    #2
    Hi Karim
    We'll take a look.

    A couple of questions:
    1) Could you show your ListGrid definition?
    I'm really interested in how you're creating rollover canvas / expansion components in this grid but if you could just paste in the definition that would probably be a useful starting point for debugging

    2) To reproduce the issue - will it happen when a user clicks the +/- buttons to expand/collapse the record or is it only occurring when your code is calling 'collapseRecord(..)' explicitly?
    If the latter, could you include the code used to get at the record component and collapse it (basically enough for me to make a little reproducible test case).

    3) What exact version of SmartGWT are you seeing this on? Is this from the public 2.1 release? A more recent snapshot (if so, what date), or something else?

    Thanks

    Isomorphic Software

    Comment


      #3
      here is my listGrid def.

      Code:
      		listGrid = new ListGrid() {  
      			private UARServerConfig serverRecord = null;
      			@Override  
      			protected Canvas getExpansionComponent(final ListGridRecord record) {  
      
      				final ListGrid grid = this;  
      				VLayout layout = new VLayout(5);  
      				layout.setPadding(5);  
      
      				String rname = record.getAttributeAsString("name");
      				for (UARServerConfig r : gRecords) {
      					if (r.getName().equals(rname)) {
      						serverRecord = r;
      						break;
      					}
      				}
      				final ServerDialog dlg = new ServerDialog(serverRecord, GenericForm.Type.EDIT, parent);
      				dlg.cancel.addClickHandler(new ClickHandler() {
      
      					@Override
      					public void onClick(ClickEvent event) {
      						// TODO Auto-generated method stub
      						grid.collapseRecord(record);
      					}
      				});
      				dlg.save.addClickHandler(new ClickHandler() {
      
      					@Override
      					public void onClick(ClickEvent event) {
      						// TODO Auto-generated method stub
      						if (dlg.isFormClosed())
      							grid.collapseRecord(record);
      					}
      				});
      				layout.addKeyPressHandler(new KeyPressHandler() {
      					public void onKeyPress(KeyPressEvent event)
      					{
      						String key = event.getKeyName();
      						if (key.equals("Escape")) {
      							grid.collapseRecord(record);
      							grid.focus();
      						}
      					}
      				});
      				layout.addMember(dlg.getLayout());  
      				return layout;  
      			}  
      			
      			@Override  
      			protected Canvas getRollOverCanvas(Integer rowNum, Integer colNum) {  
      				ListGridRecord record = this.getRecord(rowNum);  
      				String rname = record.getAttributeAsString("name");
      				for (UARServerConfig r : gRecords) {
      					if (r.getName().equals(rname)) {
      						serverRecord = r;
      						break;
      					}
      				}
      				HLayout rollOverCanvas = new HLayout(3);  
      				rollOverCanvas.setSnapTo("TR");  
      				rollOverCanvas.setWidth(50);  
      				rollOverCanvas.setHeight(22);  
      
      				ImgButton editImg = new ImgButton();  
      				editImg.setShowDown(false);  
      				editImg.setShowRollOver(false);  
      				editImg.setLayoutAlign(Alignment.CENTER);  
      				editImg.setSrc(serverRecord.isServerConfigured() ? "check.png" : "edit.png");  
      				editImg.setPrompt("Server State");  
      				editImg.setHeight(16);  
      				editImg.setWidth(16);  
      				editImg.addClickHandler(new ClickHandler() {  
      					public void onClick(ClickEvent event) {
      						if (!serverRecord.isServerConfigured())
      							SC.say("Configure Server : " + serverRecord.getName());  
      					}  
      				});  
      
      				rollOverCanvas.addMember(editImg);  
      				return rollOverCanvas;  
      
      			}  
      		};
      
      		listGrid.setWidth100();  
      		listGrid.setHeight100();  
      		listGrid.setAlternateRecordStyles(true);  
      		listGrid.setDrawAheadRatio(4);
      		listGrid.setSelectionType(SelectionStyle.MULTIPLE);
      		listGrid.setAutoFetchData(false);
      		listGrid.setShowRollOverCanvas(true);
      		listGrid.setCanExpandRecords(true);
      		listGrid.setWrapCells(false);
      		listGrid.setHoverWidth(500);
      I do not show +/- button. user expand the row by double click.

      I am using 2.1 version with 1107 nightly build.
      [ ] smartgwt-skins.jar 24-Mar-2010 17:06 4.0M
      [ ] smartgwt.jar 24-Mar-2010 17:06 8.0M


      Also I noticed that the rollover canvas stays for each row, even thought the mouse is on a different row.

      Comment


        #4
        Hi Karim
        Thanks for the code - made it easy to reproduce.
        The problem is that your getRollOverCanvas method is creating a new canvas for every row. Expected usage is to create a single roll over canvas and re-use it.
        You can use this method to *update* the single canvas you created - in your case, changing the editImg src, etc.

        Note that this differs from 'getExpansionComponent()' that method is expected to return a new component per record as you can show multiple expanded records at a time

        Thanks

        Comment


          #5
          this would explain the leftover rollover canvas, but not the listGrid.collapseRecord.

          Comment


            #6
            Did you try it? After making the change to reuse the rollover canvas the collapse record worked for me. If you're still seeing the bug let me know and I'll take another look and see if I missed something

            Comment


              #7
              Hi

              I am seeing this issue as well. Here is my getRollOverCanvas method:

              Code:
              	@Override
              	protected Canvas getRollOverCanvas(Integer rowNum, Integer colNum) {
              		rollOverRecord = this.getRecord(rowNum);
              
              		if (rollOverCanvas == null) {
              			rollOverCanvas = new HLayout(3);
              			rollOverCanvas.setSnapTo("TR");
              			rollOverCanvas.setWidth(50);
              			rollOverCanvas.setHeight(22);
              
              			Menu menu = new Menu();
              		    menu.setShowShadow(true);
              		    menu.setShadowDepth(10);
              			menu.setLayoutAlign(Alignment.LEFT);
              
              		    MenuItem deleteItem = new MenuItem("Delete Row", GWT.getModuleBaseURL() + "icon/table_row_delete.png");
              
              		    deleteItem.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {
              
              				@Override
              				public void onClick(MenuItemClickEvent event) {
              					SC.say("tester...");
              				}
              			});
              
              		    menu.addItem(deleteItem);
              			rollOverCanvas.addMember(menu);
              		}
              		return rollOverCanvas;
              	}
              I am expanding a row by clicking the row the calling grid.expandRecord() and collapsing on a subsequent click and call to grid.collapseRecord(). Interestingly I have a version of this which opens a confirm dialog (SC.ask()) before collapsing and that works just fine.

              Comment

              Working...
              X