Announcement

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

    transferSelectedData ignores setAutoSaveEdits(false)

    1) When using the "transferSelectedData" method of a listgrid, it does NOT obey the listgrid's setAutoSaveEdits(false) setting. That is, even though changes to the listgrid (ie addition of new rows; deletion of rows etc) are NOT supposed to occurr unless I call the "saveAllEdits()" method, the "transferSelectedData" seems to ignore this. the Is this the intended behaviour? If not, is there a workaround?

    On a different (but maybe) related note:

    2) If a listgrid's row's canEdit is set to false (shown below), the "remove records" button still allows the row to be removed. Is this the intended behaviour? (I would think that if the row is not editable, it should not be removable either).

    records[i].setAttribute("_canEdit", false);

    2b) Related to #2: Is there a way to overide the "remove" method that the removeRecord icon calls? I did try to override it, but it never seemed to call the removeMethod....my guess is that it's calling the javascript SmartClient removemethod directly??

    Full Infrastucture Details:
    ==================================
    SmartGWT Version: SC_SNAPSHOT-2011-12-05/PowerEdition Deployment (built 2011-12-05)

    OS: Windows XP Pro
    IDE: MyEclipse 10.0 with Google Plugin for Eclipse (2.5)
    Browser: Mozilla Firefox 4.0.1
    GWT SDK: 2.4.0
    Sun JDK 1.6.0_27

    #2
    So, I tried "addRecord", but that too called the actual add operation instead of waiting for me to explicitly call "saveAllEdits()". I did stumble upon a somehwat hoky solution, shown below:

    Code:
    arrowImgFromTree.addClickHandler(new ClickHandler() {	
    	@Override
    	public void onClick(ClickEvent event) {
    	//	lgAssignedRights.transferSelectedData(lgRightsAvailable);
    //lgAssignedRights.startEditingNew();
    int numAssignedRecords=lgAssignedRights.getRecords().length;
    
    ListGridRecord[] selectedRecords = lgRightsAvailable.getSelectedRecords();
    for (int i=0; i<selectedRecords.length; i++) {
    	//lgAssignedRights.addData(selectedRecords[i]);
    ListGridRecord selectedRecord = selectedRecords[i];
    lgAssignedRights.startEditingNew();
    lgAssignedRights.setEditValue(numAssignedRecords, 0, selectedRecord.getAttribute("username"));
    lgAssignedRights.setEditValue(numAssignedRecords, 1, selectedRecord.getAttribute("authority"));
    			lgAssignedRights.endEditing();
    			numAssignedRecords++;
    		}
    	}
    });
    But is there no bettery way? This "hack" works but has at least 1 issue so far (ie if you already have "new unsaved records" in the target listgrid, then you somehow need to figure out how many "new unsaved" records there are in order to "calculate" the next new record number, since lgAssignedRights.getRecords().length only give you the # of records for *saved* /existing records.

    Comment

    Working...
    X