Send all data from row (not only changed) during update request from ListGrid in SmartGWT

StackOverflow https://stackoverflow.com/questions/20881495

  •  23-09-2022
  •  | 
  •  

Frage

Currently I'm trying to customize SmartGWT's DataSource to work with custom REST services. And I hit into problem with sending update requests when some changes have been made in the ListGrid row. By default only changed cells in the row are sent in update request (as described here). And I want to change this behavior to send all data from the row not just edited. I've already spent a lot of time figuring out how to do this but still can't find a solution. Could you please give me any advice how to change this OOTB behavior? Probably someone has had similar problem and found the solution.

War es hilfreich?

Lösung 2

Here is the way how I implement sending all data from the row during update request. Probably it will help someone.

I overrode transformRequest method and added there such code:

@Override
protected Object transformRequest(final DSRequest dsRequest) {
    ...
    if (dsRequest.getOperationType = OperationType.UPDATE) {
       ...
       final JavaScriptObject basicJSObject = dsRequest.getOldValues().getJsObj();
       final JavaScriptObject latestChanges = dsRequest.getData();
       JSOHelper.addProperties(basicJSObject, latestChanges);

       // Regexp probably can be optimized
       final String resultString = JSON.encode(responseData)
            .replaceAll("[,]\\s*[,]", ",")
            .replaceAll("^\\s*[,]", "")
            .replaceAll("[,]\\s*$", "");

       return resultString;
    }
    ...
}

Andere Tipps

//Override the transformRequest function in DataSource //

@Override

protected void transformResponse(DSResponse response, DSRequest request, Object data){

    // On Update Operation call will hit the below condition    
    //
    if (dsRequest.getOperationType().equals(DSOperationType.UPDATE)) {

        // Get the data from listGird
        //
                    listGrid.getDataAsRecordList()

                    //Set to request 
                    //
                    dsRequest.setData();

    }

}

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top