Description
This is the contructor for a cached list.
URL
The URL of the REST API that will be used to load this list.
It is recommended that you use the GetEntryURL() action from HttpRequestHandler to generate the URL for this parameter.
comparisonAttr
Entity and attribute that will be used to check if a record is already present in the list (e.g. "User.Id");
Warning - records that were created offline cannot be matched, since we don't know their ID. Always refresh a list after creating a record.
onFinishFunction
Function that will be called when the list finishes loading data.
dontLoadData
When not null, data will not be loaded on construction (you can load it later using loadListFromServer). This is useful if you want to "lazy load" data, instead of pulling it all at once from the server.
indexWithParameters
When true, the list will be indexed, in the localStorage, using the full input URL. When false or null, the list will be indexed in the localStorage using the URL, without parameters.
e.g. index for the URL "REST_USERS.aspx?UserId=1" would be "REST_USERS.aspx", if indexWithParameters was false and it would be "REST_USERS.aspx?UserId=1" if indexWithParameters was true.
cacheApi
When specified, a request will be made to this URL to get the timestamp for the last time this list was updated. If the returned timestamp is the same as the local data's timestamp, then the list isn't fetched from the server.
dontAutoSyncWithServer
When true, dirty records in this list aren't sent to the server automatically. To save data to the server the function .saveToServer must be called explicitly.
Example
var records = OfflineApps.cachedList(
"/Offline_Sample/REST_USERS.aspx" ,
"User.Id" ,
function() {
this.loadTemplate($(".TableRecords tbody"));
this.renderList(".TableRecords tbody", null, "User.Id");
},
false ,
false
);