class MyDS extends RestDataSource { private String extraJSONParameters = ""; MyDS(LazyResponse result, String gridId, String connectionId) { this.setDataFormat(DSDataFormat.JSON); this.setDataProtocol(DSProtocol.POSTMESSAGE); /*this.setDisableQueuing(true); this.setSendMetaData(true); this.setCacheAllData(false); this.setAutoCacheAllData(false);*/ this.setDataURL("api/rest/grid"); /*this.setJsonSuffix(""); this.setJsonPrefix("");*/ DataSourceTextField[] fields = new DataSourceTextField[result.getHeaders().size()]; for (int fieldIndex = 0; fieldIndex < fields.length; fieldIndex++) { fields[fieldIndex] = new DataSourceTextField(result.getHeaders().get(fieldIndex)); } this.setFields(fields); String PROPERTY_CONNECTIONID = "connection-id"; String PROPERTY_GRIDID = "grid-id"; extraJSONParameters = "\"" + PROPERTY_CONNECTIONID + "\": \"" + connectionId + "\", \"" + PROPERTY_GRIDID + "\": \"" + gridId + "\""; OperationBinding fetchOperation = new OperationBinding(); fetchOperation.setOperationType(DSOperationType.FETCH); fetchOperation.setDataProtocol(DSProtocol.POSTMESSAGE); fetchOperation.setDataFormat(DSDataFormat.JSON); fetchOperation.setDataURL(this.getDataURL()); OperationBinding updateOperation = new OperationBinding(); updateOperation.setOperationType(DSOperationType.UPDATE); updateOperation.setDataProtocol(DSProtocol.POSTMESSAGE); updateOperation.setDataFormat(DSDataFormat.JSON); updateOperation.setDataURL(this.getDataURL()); OperationBinding addOperation = new OperationBinding(); addOperation.setOperationType(DSOperationType.ADD); addOperation.setDataProtocol(DSProtocol.POSTMESSAGE); addOperation.setDataFormat(DSDataFormat.JSON); addOperation.setDataURL(this.getDataURL()); OperationBinding deleteOperation = new OperationBinding(); addOperation.setOperationType(DSOperationType.REMOVE); addOperation.setDataProtocol(DSProtocol.POSTMESSAGE); addOperation.setDataFormat(DSDataFormat.JSON); addOperation.setDataURL(this.getDataURL()); this.setOperationBindings(fetchOperation, updateOperation, addOperation, deleteOperation); } @Override protected Object transformRequest(DSRequest dsRequest) { String message = (String) super.transformRequest(dsRequest); message = message.substring(0, message.length() - 1) + ", " + extraJSONParameters + " }"; return message; } } DataSource ds = new MyDS(result, result.getGridId(), connectionController.getConnectionId()); grid.setDataSource(ds); grid.fetchData(null, new DSCallback() { @Override public void execute(DSResponse dsResponse, Object data, DSRequest dsRequest) { grid.redraw(); grid.refreshFields(); if(grid.getTotalRows() != 0) { exportToExcelButton.enable(); } } });