Home / AJAX

Sys.Data.AdoNetServiceProxy.fetchDeferredProperty Method

RSS
Modified on 2009/11/14 19:12 by Administrator Categorized as Uncategorized

Loads data for a property that was not included with the data returned by a retrieval operation.

fetchDeferredProperty: function(item, propertyName, succeededCallback, failedCallback, userContext, webRequest)

Usage

 
exampleDataService.fetchDeferredProperty(item, propertyName, succeededCallback, failedCallback, userContext, webRequest);

Parameters

Parameter

Definition

item

A JavaScript object that contains the originally retrieved data.

propertyName

The name of the property that contains data that was not included with the retrieved data.

succeededCallback

(Optional) The function to execute when the retrieval operation succeeds.

failedCallback

(Optional) The function to execute if the retrieval operation fails.

userContext

(Optional) The state object for this operation.

webRequest

(Optional) The Sys.Net.WebRequest object to use for making the Web request instead of the default Web request object.

Return Value

The Sys.Net.WebRequest object that performed the operation.

Remarks

When a data retrieval operation includes a property in the returned data that contains a large amount of data, the property value may be excluded from the results in order to avoid problems with bandwidth or CPU processing. That is, the property might be deferred. The data is deferred until you explicitly get the property value by calling the fetchDeferredProperty method.

When a property is deferred, it does not contain data but instead contains an object that has a property named deferred. You can determine whether a property has deferred content by checking whether it contains a deferred property. For more information about how to work with deferred content in an ADO.NET Data Service, see Deferred Content.

The signatures for the callback functions must match the following examples:

 
function callbackSucceeded(result, context, operation)
function callbackFailed(error, context, operation)

The functions that you assign to the callback functions must accept three parameters. The first parameter contains a JavaScript object that represents the result (or error) that is returned by the data service. The second parameter contains a JavaScript object that represents the state object for the data operation. The third parameter contains a string value that describes the operation that was performed. For query operations, the third parameter contains the query as a string.

If you do not provide a value for the webRequest parameter, the AdoNetServiceProxy class creates a new instance of the Sys.Net.WebRequest class.

Example

The following example shows you how to use the fetchDeferredProperty method to request the data for a property that was excluded from the original results.

 
if (selectedItem.ProductSubcategory.__deferred) {
  exampleServiceProxy.fetchDeferredProperty(
    selectedItem, 
    "ProductSubcategory",
    succeededFetchDeferredCallback,
    failedFetchDeferredCallback
  );
}

See Also

Other Resources

ASP.NET AJAX Roadmap