SmartGWT version 2.5
Firefox 3.6.15
I am following the Master-detail Showcase example: http://www.smartclient.com/smartgwtee/showcase/#master_detail_batch
to manage hierarchical server data. I have a listgrid which is bound to a datasource but is configured as follows to prevent the grid from
calling the server to update/fetch. Specifically I am using ‘setSaveLocally(true)’ and ‘setAutoFetchData(false)’ to achieve this.
ListGrid listGrid = new ListGrid();
listGrid.setSaveLocally( true );
listGrid.setAutoFetchData( false );
listGrid.setSaveByCell( true );
DataSource ds = DataSource.get( Constants.ENDPOINT_MESSAGE_DATASOURCE);
listGrid.setDataSource( ds );
I am then calling setData on the grid as follows to update its contents: listGrid.setData( event.getProductData()[ 0 ].getAttributeAsRecordArray( "messages" ) );
Everything works great, the grid is updated with the data as expected. The only problem is that the first time (and only the first time) the grid is displayed I am always receiving
the following error: 'Operation type 'fetch' not supported[/B] by this DataSource (endpointMessage)'.
This message is correct, the datasource does NOT support a fetch, however that is the purpose of the setSaveLocally and setAutoFetchData
calls above, to tell the grid not to call fetch/update.
Any ideas on why is it being called?
Here is the Developer console log:
00:59:14.948:INFO:Log:isc.Page is loaded
00:59:51.997:XRP8:WARN:RPCManager:Operation type ‘fetch’ not supported by this DataSource (endpointMessage), response: {operationId: “endpointMessage_fetch”,
clientContext: Obj,
context: Obj,
transactionNum: 2,
httpResponseCode: 200,
httpResponseText: “//isc_RPCResponseStart–>[{isDSResponse:…”[179],
xmlHttpRequest: [object XMLHttpRequest],
transport: “xmlHttpRequest”,
status: -1,
clientOnly: undef,
httpHeaders: Obj,
isStructured: true,
callbackArgs: null,
results: Obj,
isDSResponse: true,
invalidateCache: false,
data: “Operation type ‘fetch’ not supported by …”[73],
startRow: 0,
endRow: 0,
totalRows: 0}
hi
I think u have problem in this declaration
DataSource ds = DataSource.get( Constants.ENDPOINT_MESSAGE_DATASOURCE);
so change to
DataSource ds = new DataSource();
BTW - I am also binding a DynamicForm to the same datasource (for editing purposes) and have called ‘setAutoFetchData’ to false as shown below.
editForm.setAutoFetchData( false );
editForm.setDataSource( DataSource.get( Constants.ENDPOINT_MESSAGE_DATASOURCE) )
Note that DynamicForm does not have a corresponding ‘setSaveLocally’ method like ListGrid. Could that be a problem?
To determine if it was the ListGrid or the DynamicForm that was calling Fetch(), I removed the DynamicForm and the problem has gone away.
So my question still remains, is there a corresponding ‘setSaveLocally( true )’
for DynamicForm to prevent it from calling fetch/update on the server?
Pls check this
setSaveLocally - in listgrid
public void setSaveLocally(Boolean saveLocally)
throws IllegalStateException
For grids with a specified dataSource, this property can be set to true to avoid the grid from attempting to save / retrieve data from the server. In this case the grid's data should be specified as an array via the data attribute, and the datasource will simply act as a schema to describe the set of fields visible in the grid. Inline edits, or removals via the canRemoveRecords mechanism will update the local data array rather than attempting to perform operations against the dataSource.
Note : This is an advanced setting
Parameters:
saveLocally - saveLocally Default value is null
Throws:
IllegalStateException - this property cannot be changed after the component has been created
See Also:
Databinding overview and related methods
Hello
In Dynamic Form ,there are methods such as
void setImplicitSave(Boolean implicitSave)
If true, form item values will be automatically saved when each item’s “editorExit” handler is fired as well as when the entire form is submitted.
void setImplicitSaveDelay(int implicitSaveDelay)
When implicitSave is true, indicates that form item values will be automatically saved after a given pause during editing, as well as when each item’s “editorExit” handler is fired and when the entire form is submitted.
Also in dynamic form,we can set the datasource and use the following method
void setClientOnly(Boolean clientOnly)
Whether to act as a “client-only” DataSource, which has no permanent storage and never contacts the server, instead using a set of test data to respond to requests in the same manner as a server-based DataSource might.
please tell,if it works..or any of my info helps u …
What type of fetch is the form trying to make? In the RPC tab you can see the originating component and other information. It’s likely to be a SelectItem trying to fetch options, or a fetch triggered due to FormItem.fetchMissingValues behavior. Both can be disabled.
Hi vinuriyer
Unfortunately none of those suggestions work
- setSaveLocally - this only applies to a ListGrid, my problem is with DynamicForm
setClientOnly - is for test data scenarios
- setImplicitSave deals with saving, my issue is with a fetch
Thanks anyway
Isomorphic,
Thanks for the reply.
As you indicated it appears a SelectItem is trying to do a fetch, though I am not sure why. I am not using an optionDataSource.
The form only has 3 SelectItem FormItems, and for all 3 I specified ‘setFetchMissingValues( false );’. The fetch is still called. The only way to prevent this behavior is to explicitly set a ValueMap for each SelectItem. I did this and all fetching has stopped.
The problem is I do not want this behavior. My 3rd SelectItem widget ‘convertToVersionItem’ dynamically derives its valueMap from those items selected in the 2nd SelectItem (‘acceptedVersionsItem’). You can see this in the ‘onFocus’ handler below:
SelectItem messageNameItem = new SelectItem( Constants.MESSAGE_ID_NAME );
messageNameItem.setTitle( Constants.MESSAGE_ID_TITLE );
messageNameItem.setWidth( 200 );
messageNameItem.setFetchMissingValues( false );
messageNameItem.setValueMap( testMessages );
SelectItem acceptedVersionsItem = new SelectItem( Constants.VERSIONS_NAME );
acceptedVersionsItem.setMultiple( true );
acceptedVersionsItem.setTitle( Constants.VERSIONS_TITLE );
acceptedVersionsItem.setMultipleAppearance( MultipleAppearance.PICKLIST );
acceptedVersionsItem.setMultipleValueSeparator( "," );
acceptedVersionsItem.setValueMap( testVersions );
acceptedVersionsItem.setAllowEmptyValue(true);
acceptedVersionsItem.setFetchMissingValues( false );
SelectItem convertToVersionItem = new SelectItem( Constants.CONVERT_TO_NAME );
convertToVersionItem.setTitle( Constants.CONVERT_TO_TITLE );
convertToVersionItem.setWidth( 100 );
convertToVersionItem.setAllowEmptyValue(true);
convertToVersionItem.setFetchMissingValues( false );
// convertToVersionItem.setValueMap( testConvert ); commenting this out causes a fetch to occur!
//convertToVersionItem valueMap should only contain items selected in acceptedVersionsItem
convertToVersionItem.addFocusHandler( new FocusHandler()
{
@Override
public void onFocus(FocusEvent event)
{
Object versionsObject = editForm.getField( Constants.VERSIONS_NAME ).getValue();
String[] versionsValues = JSOHelper.convertToJavaStringArray( (JavaScriptObject) versionsObject );
if (versionsValues != null && versionsValues.length > 0)
{
editForm.getField( Constants.CONVERT_TO_NAME ).setValueMap( versionsValues );
}
}
} );
When you specify that you want to use a SelectItem and don’t specify a valueMap, the default behavior is to use the DataSource of the form as a whole and try to select distinct values for the field from that DataSource. To prevent this, you can set an empty valueMap until you have calculated the actual valueMap you want to use.