Announcement

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

    Interaction of ListGrid.saveAllEdits() and ListGrid.getRecord(int recordNum)

    Hi,

    I've been experimenting with the GridMassUpdateSample. I've replaced the save button's click handler with the following:

    Code:
            saveButton.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                	
                	int i = 0; 
                	ListGridRecord record = countryGrid.getRecord(i);
                	            	
                	String beforeSave = 
                		"Before save values for record " + i + ": " + 
    	        		record.getAttributeAsString("countryCode") + ", " +
    	        		record.getAttributeAsString("countryName") + ", " +
    	        		record.getAttributeAsBoolean("member_g8") + ", " +
    	        		record.getAttributeAsString("continent") + ", " +
    	        		record.getAttributeAsDate("independence") + ", " +
    	        		record.getAttributeAsInt("population"); 
                	
                	countryGrid.saveAllEdits();            	                                          
    				
    				ListGridRecord recordAfter = countryGrid.getRecord(i);
    				
                	String afterSave = 
                		"After save values for record " + i + ": " + 
    	        		recordAfter.getAttributeAsString("countryCode") + ", " +
    	        		recordAfter.getAttributeAsString("countryName") + ", " +
    	        		recordAfter.getAttributeAsBoolean("member_g8") + ", " +
    	        		recordAfter.getAttributeAsString("continent") + ", " +
    	        		recordAfter.getAttributeAsDate("independence") + ", " +
    	        		recordAfter.getAttributeAsInt("population"); 
                	
                	
                    SC.say(beforeSave + "<BR>" + afterSave);
                }
            });
            canvas.addChild(saveButton);
    This displays the results of calling ListGrid's getRecord(int recordNum) method before and after calling ListGrid's saveAllEdits() method.

    If I edit the first row in the table, for example by changing the country name from "United States" to "United StatesA" and then press the Save button, the popup shows the name "United States" (no A) both before and after the save. If I press the Save button again, it now shows "United StatesA" both before and after the save. Is this behaviour correct?

    Thanks,

    Andrew

    #2
    Yes - saveAllEdits() is asychronous but you are checking the values synchronously. Using the callback argument of saveAllEdits() to see the values after the save completes.

    Comment


      #3
      The saveAllEdits method with the optional saveCallback argument is not in yet. Will add it in the next build.

      Sanjiv

      Comment

      Working...
      X