@mescius/wijmo.odata 5.20232.939
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/COMMERCIAL-LICENSE.html +485 -0
- package/README.md +363 -0
- package/es2015-commonjs.js +14 -0
- package/es2015-esm.js +14 -0
- package/es5-esm.js +14 -0
- package/index.d.ts +641 -0
- package/index.js +14 -0
- package/package.json +47 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,641 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
*
|
|
3
|
+
* Wijmo Library 5.20232.939
|
|
4
|
+
* https://developer.mescius.com/wijmo
|
|
5
|
+
*
|
|
6
|
+
* Copyright(c) MESCIUS inc. All rights reserved.
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the End-User License Agreement For MESCIUS Wijmo Software.
|
|
9
|
+
* us.sales@mescius.com
|
|
10
|
+
* https://developer.mescius.com/wijmo/licensing
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* {@module wijmo.odata}
|
|
15
|
+
* Provides classes that support the OData protocol, including the
|
|
16
|
+
* {@link ODataCollectionView} class.
|
|
17
|
+
*
|
|
18
|
+
* OData is a standardized protocol for creating and consuming data APIs.
|
|
19
|
+
* OData builds on core protocols like HTTP and commonly accepted
|
|
20
|
+
* methodologies like REST.
|
|
21
|
+
* The result is a uniform way to expose full-featured data APIs.
|
|
22
|
+
* (https://www.odata.org/)
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
*/
|
|
27
|
+
export declare var ___keepComment: any;
|
|
28
|
+
import { Event, EventArgs, RequestErrorEventArgs, CollectionView, PageChangingEventArgs } from '@grapecity/wijmo';
|
|
29
|
+
import * as mGrid from '@grapecity/wijmo.grid';
|
|
30
|
+
import * as mFilter from '@grapecity/wijmo.grid.filter';
|
|
31
|
+
import * as selfModule from '@grapecity/wijmo.odata';
|
|
32
|
+
export declare function softGrid(): typeof mGrid;
|
|
33
|
+
export declare function softFilter(): typeof mFilter;
|
|
34
|
+
/**
|
|
35
|
+
* Extends the {@link CollectionView} class to support loading and
|
|
36
|
+
* saving data from OData sources.
|
|
37
|
+
*
|
|
38
|
+
* You can use the {@link ODataCollectionView} class to load data from
|
|
39
|
+
* OData services and use it as a data source for Wijmo controls.
|
|
40
|
+
*
|
|
41
|
+
* In addition to full CRUD support you get all the {@link CollectionView}
|
|
42
|
+
* features including sorting, filtering, paging, and grouping.
|
|
43
|
+
* The sorting, filtering, and paging functions may be performed on the
|
|
44
|
+
* server or on the client.
|
|
45
|
+
*
|
|
46
|
+
* The code below shows how you can instantiate an {@link ODataCollectionView}
|
|
47
|
+
* that selects some fields from the data source and provides sorting on the
|
|
48
|
+
* client.
|
|
49
|
+
* Notice how the 'options' parameter is used to pass in initialization
|
|
50
|
+
* data, which is the same approach used when initializing controls:
|
|
51
|
+
*
|
|
52
|
+
* ```typescript
|
|
53
|
+
* import { ODataCollectionView } from '@grapecity/wijmo.odata';
|
|
54
|
+
* const url = 'http://services.odata.org/V4/Northwind/Northwind.svc/';
|
|
55
|
+
* const categories = new ODataCollectionView(url, 'Categories', {
|
|
56
|
+
* fields: ['CategoryID', 'CategoryName', 'Description'],
|
|
57
|
+
* sortOnServer: false
|
|
58
|
+
* });
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* The example below uses an {@link ODataCollectionView} to load data from
|
|
62
|
+
* a NorthWind OData provider service, and shows the result in a
|
|
63
|
+
* {@link FlexGrid} control:
|
|
64
|
+
*
|
|
65
|
+
* {@sample Grid/Data-binding/ODataAPI/purejs Example}
|
|
66
|
+
*/
|
|
67
|
+
export declare class ODataCollectionView extends CollectionView {
|
|
68
|
+
_url: string;
|
|
69
|
+
_tbl: string;
|
|
70
|
+
_entityType: string;
|
|
71
|
+
_count: number;
|
|
72
|
+
_fields: string[];
|
|
73
|
+
_keys: string[];
|
|
74
|
+
_expand: string;
|
|
75
|
+
_dataTypes: any;
|
|
76
|
+
_sortOnServer: boolean;
|
|
77
|
+
_pageOnServer: boolean;
|
|
78
|
+
_filterOnServer: boolean;
|
|
79
|
+
_deferCommits: boolean;
|
|
80
|
+
_hasPendingChanges: boolean;
|
|
81
|
+
_showDatesAsGmt: boolean;
|
|
82
|
+
_inferDataTypes: boolean;
|
|
83
|
+
_dataTypesInferred: any;
|
|
84
|
+
_reviverBnd: any;
|
|
85
|
+
_jsonReviver: Function;
|
|
86
|
+
_filterDef: string;
|
|
87
|
+
_toGetData: any;
|
|
88
|
+
_loading: boolean;
|
|
89
|
+
_requestHeaders: any;
|
|
90
|
+
_odv: number;
|
|
91
|
+
static _odvCache: {};
|
|
92
|
+
static _rxDate: RegExp;
|
|
93
|
+
/**
|
|
94
|
+
* Initializes a new instance of the {@link ODataCollectionView} class.
|
|
95
|
+
*
|
|
96
|
+
* @param url Url of the OData service (for example
|
|
97
|
+
* https://services.odata.org/Northwind/Northwind.svc/ ).
|
|
98
|
+
* @param tableName Name of the table (entity) to retrieve from the service.
|
|
99
|
+
* If not provided, a list of the tables (entities) available is retrieved.
|
|
100
|
+
* @param options JavaScript object containing initialization data (property
|
|
101
|
+
* values and event handlers) for the {@link ODataCollectionView}.
|
|
102
|
+
*/
|
|
103
|
+
constructor(url: string, tableName: string, options?: any);
|
|
104
|
+
/**
|
|
105
|
+
* Gets the name of the table (entity) that this collection is bound to.
|
|
106
|
+
*/
|
|
107
|
+
readonly tableName: string;
|
|
108
|
+
/**
|
|
109
|
+
* Gets or sets a string that represents the entity's data type on the server.
|
|
110
|
+
*
|
|
111
|
+
* This may be required to update data in some OData services.
|
|
112
|
+
*
|
|
113
|
+
* For more details, please see
|
|
114
|
+
* http://docs.oasis-open.org/odata/odata-json-format/v4.0/cs01/odata-json-format-v4.0-cs01.html#_Toc365464687.
|
|
115
|
+
*/
|
|
116
|
+
entityType: string;
|
|
117
|
+
/**
|
|
118
|
+
* Gets or sets an array containing the names of the fields to retrieve from
|
|
119
|
+
* the data source.
|
|
120
|
+
*
|
|
121
|
+
* If this property is set to null or to an empty array, all fields are
|
|
122
|
+
* retrieved.
|
|
123
|
+
*
|
|
124
|
+
* For example, the code below creates an {@link ODataCollectionView} that
|
|
125
|
+
* gets only three fields from the 'Categories' table in the database:
|
|
126
|
+
*
|
|
127
|
+
* ```typescript
|
|
128
|
+
* import { ODataCollectionView } from '@grapecity/wijmo.odata';
|
|
129
|
+
* const url = 'http://services.odata.org/V4/Northwind/Northwind.svc/';
|
|
130
|
+
* const categories = new ODataCollectionView(url, 'Categories', {
|
|
131
|
+
* fields: ['CategoryID', 'CategoryName', 'Description']
|
|
132
|
+
* });
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
fields: string[];
|
|
136
|
+
/**
|
|
137
|
+
* Gets or sets an object containing request headers to be used when sending
|
|
138
|
+
* or requesting data.
|
|
139
|
+
*
|
|
140
|
+
* The most typical use for this property is in scenarios where authentication
|
|
141
|
+
* is required. For example:
|
|
142
|
+
*
|
|
143
|
+
* ```typescript
|
|
144
|
+
* import { ODataCollectionView } from '@grapecity/wijmo.odata';
|
|
145
|
+
* const url = 'http://services.odata.org/V4/Northwind/Northwind.svc/';
|
|
146
|
+
* const categories = new ODataCollectionView(serviceUrl, 'Categories', {
|
|
147
|
+
* fields: ['Category_ID', 'Category_Name'],
|
|
148
|
+
* requestHeaders: { Authorization: db.token }
|
|
149
|
+
* });
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
requestHeaders: any;
|
|
153
|
+
/**
|
|
154
|
+
* Gets or sets an array containing the names of the key fields.
|
|
155
|
+
*
|
|
156
|
+
* Key fields are required for update operations (add/remove/delete).
|
|
157
|
+
*/
|
|
158
|
+
keys: string[];
|
|
159
|
+
/**
|
|
160
|
+
* Gets or sets a string that specifies whether related entities should
|
|
161
|
+
* be included in the return data.
|
|
162
|
+
*
|
|
163
|
+
* This property maps directly to OData's $expand option.
|
|
164
|
+
*
|
|
165
|
+
* For example, the code below retrieves all the customers and their
|
|
166
|
+
* orders from the database. Each customer entity has an "Orders"
|
|
167
|
+
* field that contains an array of order objects:
|
|
168
|
+
*
|
|
169
|
+
* ```typescript
|
|
170
|
+
* import { ODataCollectionView } from '@grapecity/wijmo.odata';
|
|
171
|
+
* const url = 'http://services.odata.org/V4/Northwind/Northwind.svc/';
|
|
172
|
+
* const customersOrders = new ODataCollectionView(url, 'Customers', {
|
|
173
|
+
* expand: 'Orders'
|
|
174
|
+
* });
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
expand: string;
|
|
178
|
+
/**
|
|
179
|
+
* Gets or sets a custom reviver function to use when parsing JSON
|
|
180
|
+
* values returned from the server.
|
|
181
|
+
*
|
|
182
|
+
* If provided, the function must take two parameters (key and value),
|
|
183
|
+
* and must return the parsed value (which can be the same as the
|
|
184
|
+
* original value).
|
|
185
|
+
*
|
|
186
|
+
* For details about reviver functions, please refer to the documentation
|
|
187
|
+
* for the
|
|
188
|
+
* <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse" target="_blank">JSON.parse method</a>.
|
|
189
|
+
*/
|
|
190
|
+
jsonReviver: Function;
|
|
191
|
+
/**
|
|
192
|
+
* Gets or sets a JavaScript object to be used as a map for coercing data types
|
|
193
|
+
* when loading the data.
|
|
194
|
+
*
|
|
195
|
+
* The object keys represent the field names and the values are {@link DataType} values
|
|
196
|
+
* that indicate how the data should be coerced.
|
|
197
|
+
*
|
|
198
|
+
* For example, the code below creates an {@link ODataCollectionView} and specifies
|
|
199
|
+
* that 'Freight' values, which are stored as strings in the database, should be
|
|
200
|
+
* converted into numbers; and that three date fields should be converted into dates:
|
|
201
|
+
*
|
|
202
|
+
* ```typescript
|
|
203
|
+
* import { ODataCollectionView } from '@grapecity/wijmo.odata';
|
|
204
|
+
* import { DataType } from '@grapecity/wijmo';
|
|
205
|
+
* const url = 'http://services.odata.org/V4/Northwind/Northwind.svc/';
|
|
206
|
+
* const orders = new ODataCollectionView(url, 'Orders', {
|
|
207
|
+
* dataTypes: {
|
|
208
|
+
* Freight: DataType.Number
|
|
209
|
+
* OrderDate: DataType.Date,
|
|
210
|
+
* RequiredDate: DataType.Date,
|
|
211
|
+
* ShippedDate: DataType.Date,
|
|
212
|
+
* }
|
|
213
|
+
* });
|
|
214
|
+
* ```
|
|
215
|
+
*
|
|
216
|
+
* This property is useful when the database contains data stored in
|
|
217
|
+
* formats that do not conform to common usage.
|
|
218
|
+
*
|
|
219
|
+
* In most cases you don't have to provide information about the
|
|
220
|
+
* data types, because the {@link inferDataTypes} property handles
|
|
221
|
+
* the conversion of Date values automatically.
|
|
222
|
+
*
|
|
223
|
+
* If you do provide explicit type information, the {@link inferDataTypes}
|
|
224
|
+
* property is not applied. Because of this, any data type information
|
|
225
|
+
* that is provided should be complete, including all fields of type
|
|
226
|
+
* Date.
|
|
227
|
+
*/
|
|
228
|
+
dataTypes: any;
|
|
229
|
+
/**
|
|
230
|
+
* Gets or sets a value that determines whether fields that contain
|
|
231
|
+
* strings that look like standard date representations should be
|
|
232
|
+
* converted to dates automatically.
|
|
233
|
+
*
|
|
234
|
+
* This property is set to true by default, because the {@link ODataCollectionView}
|
|
235
|
+
* class uses JSON and that format does not support Date objects.
|
|
236
|
+
*
|
|
237
|
+
* This property has no effect if specific type information is provided using
|
|
238
|
+
* the {@link dataTypes} property.
|
|
239
|
+
*/
|
|
240
|
+
inferDataTypes: boolean;
|
|
241
|
+
/**
|
|
242
|
+
* Gets or sets a value that determines whether dates should be adjusted
|
|
243
|
+
* to look like GMT rather than local dates.
|
|
244
|
+
*/
|
|
245
|
+
showDatesAsGmt: boolean;
|
|
246
|
+
/**
|
|
247
|
+
* Gets or sets a value that determines whether sort operations
|
|
248
|
+
* should be performed on the server or on the client.
|
|
249
|
+
*
|
|
250
|
+
* Use the {@link sortDescriptions} property to specify how the
|
|
251
|
+
* data should be sorted.
|
|
252
|
+
*
|
|
253
|
+
* The default value for this property is **true**.
|
|
254
|
+
*/
|
|
255
|
+
sortOnServer: boolean;
|
|
256
|
+
/**
|
|
257
|
+
* Gets or sets a value that determines whether paging should be
|
|
258
|
+
* performed on the server or on the client.
|
|
259
|
+
*
|
|
260
|
+
* Use the {@link pageSize} property to enable paging.
|
|
261
|
+
*
|
|
262
|
+
* The default value for this property is **true**.
|
|
263
|
+
*/
|
|
264
|
+
pageOnServer: boolean;
|
|
265
|
+
/**
|
|
266
|
+
* Gets or sets a value that determines whether filtering should be
|
|
267
|
+
* performed on the server or on the client.
|
|
268
|
+
*
|
|
269
|
+
* Use the {@link filter} property to perform filtering on the client,
|
|
270
|
+
* and use the {@link filterDefinition} property to perform filtering
|
|
271
|
+
* on the server.
|
|
272
|
+
*
|
|
273
|
+
* In some cases it may be desirable to apply independent filters
|
|
274
|
+
* on the client **and** on the server.
|
|
275
|
+
*
|
|
276
|
+
* You can achieve this by setting (1) the {@link filterOnServer} property
|
|
277
|
+
* to false and the {@link filter} property to a filter function (to enable
|
|
278
|
+
* client-side filtering) and (2) the {@link filterDefinition} property to
|
|
279
|
+
* a filter string (to enable server-side filtering).
|
|
280
|
+
*
|
|
281
|
+
* The default value for this property is **true**.
|
|
282
|
+
*/
|
|
283
|
+
filterOnServer: boolean;
|
|
284
|
+
/**
|
|
285
|
+
* Gets or sets a string containing an OData filter specification to
|
|
286
|
+
* be used for filtering the data on the server.
|
|
287
|
+
*
|
|
288
|
+
* The filter definition syntax is described in the
|
|
289
|
+
* <a href="https://www.odata.org/documentation/odata-version-2-0/uri-conventions/">OData documentation</a>.
|
|
290
|
+
*
|
|
291
|
+
* For example, the code below causes the server to return records
|
|
292
|
+
* where the 'CompanyName' field starts with 'A' and ends with 'S':
|
|
293
|
+
*
|
|
294
|
+
* ```typescript
|
|
295
|
+
* view.filterDefinition = "startswith(CompanyName, 'A') and endswith(CompanyName, 'B')";
|
|
296
|
+
* ```
|
|
297
|
+
*
|
|
298
|
+
* Filter definitions can be generated automatically. For example, the
|
|
299
|
+
* {@link FlexGridFilter} component detects whether its data source is an
|
|
300
|
+
* {@link ODataCollectionView} and automatically updates both the
|
|
301
|
+
* {@link ODataCollectionView.filter} and {@link ODataCollectionView.filterDefinition}
|
|
302
|
+
* properties.
|
|
303
|
+
*
|
|
304
|
+
* Note that the {@link ODataCollectionView.filterDefinition} property is applied
|
|
305
|
+
* even if the {@link ODataCollectionView.filterOnServer} property is set to false.
|
|
306
|
+
* This allows you to apply server and client filters to the same collection,
|
|
307
|
+
* which can be useful in many scenarios.
|
|
308
|
+
*
|
|
309
|
+
* For example, the code below uses the {@link ODataCollectionView.filterDefinition}
|
|
310
|
+
* property to filter on the server and the {@link ODataCollectionView.filter}
|
|
311
|
+
* property to further filter on the client. The collection will show items with
|
|
312
|
+
* names that start with 'C' and have unit prices greater than 20:
|
|
313
|
+
*
|
|
314
|
+
* ```typescript
|
|
315
|
+
* import { ODataCollectionView } from '@grapecity/wijmo.odata';
|
|
316
|
+
* const url = 'http://services.odata.org/V4/Northwind/Northwind.svc/';
|
|
317
|
+
* const data = new ODataCollectionView(url, 'Products', {
|
|
318
|
+
* oDataVersion: 4,
|
|
319
|
+
* filterDefinition: 'startswith(ProductName, \'C\')', // server filter
|
|
320
|
+
* filterOnServer: false, // client filter
|
|
321
|
+
* filter: function(product) {
|
|
322
|
+
* return product.UnitPrice > 20;
|
|
323
|
+
* },
|
|
324
|
+
* });
|
|
325
|
+
* ```
|
|
326
|
+
*/
|
|
327
|
+
filterDefinition: string;
|
|
328
|
+
/**
|
|
329
|
+
* Updates the filter definition based on a known filter provider such as the
|
|
330
|
+
* {@link FlexGridFilter}.
|
|
331
|
+
*
|
|
332
|
+
* @param filterProvider Known filter provider, typically an instance of a
|
|
333
|
+
* {@link FlexGridFilter}.
|
|
334
|
+
*/
|
|
335
|
+
updateFilterDefinition(filterProvider: any): void;
|
|
336
|
+
/**
|
|
337
|
+
* Gets or sets the OData version used by the server.
|
|
338
|
+
*
|
|
339
|
+
* There are currently four versions of OData services, 1.0 through 4.0.
|
|
340
|
+
* Version 4.0 is used by the latest services, but there are many legacy
|
|
341
|
+
* services still in operation.
|
|
342
|
+
*
|
|
343
|
+
* If you know what version of OData your service implements, set the
|
|
344
|
+
* {@link oDataVersion} property to the appropriate value (1 through 4) when
|
|
345
|
+
* creating the {@link ODataCollectionView} (see example below).
|
|
346
|
+
*
|
|
347
|
+
* ```typescript
|
|
348
|
+
* import { ODataCollectionView } from '@grapecity/wijmo.odata';
|
|
349
|
+
* let url = 'https://services.odata.org/Northwind/Northwind.svc/';
|
|
350
|
+
* let categories = new ODataCollectionView(url, 'Categories', {
|
|
351
|
+
* oDataVersion: 1.0, // legacy OData source
|
|
352
|
+
* fields: ['CategoryID', 'CategoryName', 'Description'],
|
|
353
|
+
* sortOnServer: false
|
|
354
|
+
* });
|
|
355
|
+
* ```
|
|
356
|
+
*
|
|
357
|
+
* If you do not know what version of OData your service implements (perhaps
|
|
358
|
+
* you are writing an OData explorer application), then do not specify the
|
|
359
|
+
* version. In this case, the {@link ODataCollectionView} will get this information
|
|
360
|
+
* from the server. This operation requires an extra request, but only once
|
|
361
|
+
* per service URL, so the overhead is small.
|
|
362
|
+
*/
|
|
363
|
+
oDataVersion: number;
|
|
364
|
+
/**
|
|
365
|
+
* Gets a value that indicates the {@link ODataCollectionView} is
|
|
366
|
+
* currently loading data.
|
|
367
|
+
*
|
|
368
|
+
* This property can be used to provide progress indicators.
|
|
369
|
+
*/
|
|
370
|
+
readonly isLoading: boolean;
|
|
371
|
+
/**
|
|
372
|
+
* Gets or sets a value that causes the {@link ODataCollectionView} to
|
|
373
|
+
* defer commits back to the database.
|
|
374
|
+
*
|
|
375
|
+
* The default value for this property is **false**, which causes
|
|
376
|
+
* any changes to the data to be immediately committed to the database.
|
|
377
|
+
*
|
|
378
|
+
* If you set this property to **true**, it will automatically set the
|
|
379
|
+
* {@link trackChanges} property to true. After this, any changes to the
|
|
380
|
+
* data (including edits, additions, and removals) will be tracked but
|
|
381
|
+
* not committed to the database until you call the {@link commitChanges}
|
|
382
|
+
* method to commit the changes, or the {@link cancelChanges} method
|
|
383
|
+
* to discard all pending changes.
|
|
384
|
+
*
|
|
385
|
+
* For example:
|
|
386
|
+
* ```typescript
|
|
387
|
+
* import { ODataCollectionView } from '@grapecity/wijmo.odata';
|
|
388
|
+
*
|
|
389
|
+
* // create data source
|
|
390
|
+
* let url = 'https://services.odata.org/...';
|
|
391
|
+
* let view = new ODataCollectionView(url, 'Categories', {
|
|
392
|
+
* keys: [ 'ID' ]
|
|
393
|
+
* });
|
|
394
|
+
*
|
|
395
|
+
* // defer commits
|
|
396
|
+
* view.deferCommits = true;
|
|
397
|
+
*
|
|
398
|
+
* // handle commit/cancel changes buttons
|
|
399
|
+
* let btnCommit = document.getElementById('btn-commit') as HTMLButtonElement,
|
|
400
|
+
* btnCancel = document.getElementById('btn-cancel') as HTMLButtonElement;
|
|
401
|
+
* btnCommit.addEventListener('click', () => view.commitChanges());
|
|
402
|
+
* btnCancel.addEventListener('click', () => view.cancelChanges());
|
|
403
|
+
* view.hasPendingChangesChanged.addHandler((s, e) => {
|
|
404
|
+
* btnCommit.disabled = btnCancel.disabled = !view.hasPendingChanges;
|
|
405
|
+
* });
|
|
406
|
+
* ```
|
|
407
|
+
*/
|
|
408
|
+
deferCommits: boolean;
|
|
409
|
+
/**
|
|
410
|
+
* Occurs when the {@link ODataCollectionView} starts loading data.
|
|
411
|
+
*/
|
|
412
|
+
readonly loading: Event<ODataCollectionView, EventArgs>;
|
|
413
|
+
/**
|
|
414
|
+
* Raises the {@link loading} event.
|
|
415
|
+
*/
|
|
416
|
+
onLoading(e?: EventArgs): void;
|
|
417
|
+
/**
|
|
418
|
+
* Occurs when the {@link ODataCollectionView} finishes loading data.
|
|
419
|
+
*/
|
|
420
|
+
readonly loaded: Event<ODataCollectionView, EventArgs>;
|
|
421
|
+
/**
|
|
422
|
+
* Raises the {@link loaded} event.
|
|
423
|
+
*/
|
|
424
|
+
onLoaded(e?: EventArgs): void;
|
|
425
|
+
/**
|
|
426
|
+
* Loads or re-loads the data from the OData source.
|
|
427
|
+
*/
|
|
428
|
+
load(): void;
|
|
429
|
+
/**
|
|
430
|
+
* Occurs when there is an error reading or writing data.
|
|
431
|
+
*/
|
|
432
|
+
readonly error: Event<ODataCollectionView, RequestErrorEventArgs>;
|
|
433
|
+
/**
|
|
434
|
+
* Raises the {@link error} event.
|
|
435
|
+
*
|
|
436
|
+
* By default, errors throw exceptions and trigger a data refresh. If you
|
|
437
|
+
* want to prevent this behavior, set the {@link RequestErrorEventArgs.cancel}
|
|
438
|
+
* parameter to true in the event handler.
|
|
439
|
+
*
|
|
440
|
+
* @param e {@link RequestErrorEventArgs} that contains information about the error.
|
|
441
|
+
*/
|
|
442
|
+
onError(e: RequestErrorEventArgs): boolean;
|
|
443
|
+
/**
|
|
444
|
+
* Occurs when the value of the {@link hasPendingChanges} property changes.
|
|
445
|
+
*
|
|
446
|
+
* See also the {@link deferCommits} property.
|
|
447
|
+
*/
|
|
448
|
+
readonly hasPendingChangesChanged: Event<ODataCollectionView, EventArgs>;
|
|
449
|
+
/**
|
|
450
|
+
* Raises the {@link hasPendingChangesChanged} event.
|
|
451
|
+
*/
|
|
452
|
+
onHasPendingChangesChanged(e?: EventArgs): void;
|
|
453
|
+
/**
|
|
454
|
+
* Returns true if this object supports a given interface.
|
|
455
|
+
*
|
|
456
|
+
* @param interfaceName Name of the interface to look for.
|
|
457
|
+
*/
|
|
458
|
+
implementsInterface(interfaceName: string): boolean;
|
|
459
|
+
/**
|
|
460
|
+
* Override {@link commitNew} to add the new item to the database.
|
|
461
|
+
*/
|
|
462
|
+
commitNew(): void;
|
|
463
|
+
/**
|
|
464
|
+
* Override {@link commitEdit} to modify the item in the database.
|
|
465
|
+
*/
|
|
466
|
+
commitEdit(): void;
|
|
467
|
+
/**
|
|
468
|
+
* Override {@link remove} to remove the item from the database.
|
|
469
|
+
*
|
|
470
|
+
* @param item Item to be removed from the database.
|
|
471
|
+
*/
|
|
472
|
+
remove(item: any): void;
|
|
473
|
+
/**
|
|
474
|
+
* Commits all pending changes to the server.
|
|
475
|
+
*
|
|
476
|
+
* Changes are contained in the {@link itemsEdited}, {@link itemsAdded},
|
|
477
|
+
* and {@link itemsRemoved} collections, and are automatically cleared
|
|
478
|
+
* after they are committed.
|
|
479
|
+
*
|
|
480
|
+
* See also the {@link deferCommits} property.
|
|
481
|
+
*
|
|
482
|
+
* @param committed Optional callback invoked when the commit operation
|
|
483
|
+
* has been completed. The callback takes an **XMLHttpRequest**
|
|
484
|
+
* parameter contains information about the request results.
|
|
485
|
+
*/
|
|
486
|
+
commitChanges(committed?: (xhr: XMLHttpRequest) => void): void;
|
|
487
|
+
/**
|
|
488
|
+
* Cancels all changes by removing all items in the {@link itemsAdded},
|
|
489
|
+
* {@link itemsRemoved}, and {@link itemsEdited} collections,
|
|
490
|
+
* without committing them to the server.
|
|
491
|
+
*
|
|
492
|
+
* This method is used with the {@link deferCommits} property.
|
|
493
|
+
*/
|
|
494
|
+
cancelChanges(): void;
|
|
495
|
+
/**
|
|
496
|
+
* Gets a value that determines whether the {@link ODataCollectionView} has
|
|
497
|
+
* pending changes.
|
|
498
|
+
*
|
|
499
|
+
* See also the {@link deferCommits} property and the
|
|
500
|
+
* {@link commitChanges} and {@link cancelChanges} methods.
|
|
501
|
+
*/
|
|
502
|
+
readonly hasPendingChanges: boolean;
|
|
503
|
+
/**
|
|
504
|
+
* Gets the total number of items in the view before paging is applied.
|
|
505
|
+
*/
|
|
506
|
+
readonly totalItemCount: number;
|
|
507
|
+
/**
|
|
508
|
+
* Gets the total number of pages.
|
|
509
|
+
*/
|
|
510
|
+
readonly pageCount: number;
|
|
511
|
+
/**
|
|
512
|
+
* Gets or sets the number of items to display on a page.
|
|
513
|
+
*/
|
|
514
|
+
pageSize: number;
|
|
515
|
+
/**
|
|
516
|
+
* Raises the {@link pageChanging} event.
|
|
517
|
+
*
|
|
518
|
+
* @param e {@link PageChangingEventArgs} that contains the event data.
|
|
519
|
+
*/
|
|
520
|
+
onPageChanging(e: PageChangingEventArgs): boolean;
|
|
521
|
+
_getPageView(): any[];
|
|
522
|
+
_performRefresh(): void;
|
|
523
|
+
_updateHasChanges(): void;
|
|
524
|
+
_storeItems(items: any[], append: boolean): void;
|
|
525
|
+
_getReadUrl(nextLink?: string): string;
|
|
526
|
+
_getReadParams(nextLink?: string): any;
|
|
527
|
+
_getData(nextLink?: string, xhrCallback?: Function): void;
|
|
528
|
+
private _convertToDbFormat;
|
|
529
|
+
private _reviver;
|
|
530
|
+
private _convertItem;
|
|
531
|
+
private _getInferredDataTypes;
|
|
532
|
+
private _getServiceUrl;
|
|
533
|
+
private _getSchema;
|
|
534
|
+
private _getWriteUrl;
|
|
535
|
+
private _asODataFilter;
|
|
536
|
+
private _asODataValueFilter;
|
|
537
|
+
private _asEquals;
|
|
538
|
+
private _asODataConditionFilter;
|
|
539
|
+
private _asODataCondition;
|
|
540
|
+
private _asODataValue;
|
|
541
|
+
private _error;
|
|
542
|
+
private _encodeBatch;
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Extends the {@link ODataCollectionView} class to support loading data on
|
|
546
|
+
* demand, using the {@link setWindow} method.
|
|
547
|
+
*
|
|
548
|
+
* The example below shows how you can declare an {@link ODataCollectionView}
|
|
549
|
+
* and synchronize it with a {@link wijmo.grid.FlexGrid} control to load the
|
|
550
|
+
* data that is within the grid's viewport:
|
|
551
|
+
*
|
|
552
|
+
* ```typescript
|
|
553
|
+
* // declare virtual collection view
|
|
554
|
+
* let view = new wijmo.odata.ODataVirtualCollectionView(url, 'Order_Details_Extendeds', {
|
|
555
|
+
* oDataVersion: 4
|
|
556
|
+
* });
|
|
557
|
+
*
|
|
558
|
+
* // use virtual collection as grid data source
|
|
559
|
+
* flex.itemsSource = view;
|
|
560
|
+
*
|
|
561
|
+
* // update data window when the grid scrolls
|
|
562
|
+
* flex.scrollPositionChanged.addHandler(() => {
|
|
563
|
+
* let rng = flex.viewRange;
|
|
564
|
+
* view.setWindow(rng.topRow, rng.bottomRow);
|
|
565
|
+
* });
|
|
566
|
+
* ```
|
|
567
|
+
*
|
|
568
|
+
* The {@link ODataVirtualCollectionView} class implements a 'data window' so only
|
|
569
|
+
* data that is actually being displayed is loaded from the server. Items that are
|
|
570
|
+
* not being displayed are added to the collection as null values until a call
|
|
571
|
+
* to the {@link setWindow} method causes them those items to be loaded.
|
|
572
|
+
*
|
|
573
|
+
* This 'on-demand' method of loading data has advantages when dealing with large
|
|
574
|
+
* data sets, because it prevents the application from loading data until it is
|
|
575
|
+
* required. But it does impose some limitation: sorting and filtering must be
|
|
576
|
+
* done on the server; grouping and paging are not supported.
|
|
577
|
+
*
|
|
578
|
+
* The example below uses an {@link ODataVirtualCollectionView} to load data from
|
|
579
|
+
* a NorthWind OData provider service. The collection loads data on-demant,
|
|
580
|
+
* as the user scrolls the grid:
|
|
581
|
+
*
|
|
582
|
+
* {@sample Grid/Data-binding/VirtualOData/purejs Example}
|
|
583
|
+
*/
|
|
584
|
+
export declare class ODataVirtualCollectionView extends ODataCollectionView {
|
|
585
|
+
_data: any[];
|
|
586
|
+
_start: number;
|
|
587
|
+
_end: number;
|
|
588
|
+
_refresh: boolean;
|
|
589
|
+
_loadOffset: number;
|
|
590
|
+
_toSetWindow: any;
|
|
591
|
+
_pendingRequest: XMLHttpRequest;
|
|
592
|
+
_requestCanceled: Event<ODataVirtualCollectionView, EventArgs>;
|
|
593
|
+
_firstLoad: boolean;
|
|
594
|
+
/**
|
|
595
|
+
* Initializes a new instance of the {@link ODataVirtualCollectionView} class.
|
|
596
|
+
*
|
|
597
|
+
* @param url Url of the OData service (for example
|
|
598
|
+
* https://services.odata.org/Northwind/Northwind.svc/ ).
|
|
599
|
+
* @param tableName Name of the table (entity) to retrieve from the service.
|
|
600
|
+
* If not provided, a list of the tables (entities) available is retrieved.
|
|
601
|
+
* @param options JavaScript object containing initialization data (property
|
|
602
|
+
* values and event handlers) for the {@link ODataVirtualCollectionView}.
|
|
603
|
+
*/
|
|
604
|
+
constructor(url: string, tableName: string, options?: any);
|
|
605
|
+
/**
|
|
606
|
+
* Sets the data window to ensure a range of records are loaded into the view.
|
|
607
|
+
*
|
|
608
|
+
* @param start Index of the first item in the data window.
|
|
609
|
+
* @param end Index of the last item in the data window.
|
|
610
|
+
*/
|
|
611
|
+
setWindow(start: number, end: number): void;
|
|
612
|
+
/**
|
|
613
|
+
* Occurs when the {@link ODataVirtualCollectionView} cancels a pending data request.
|
|
614
|
+
*/
|
|
615
|
+
readonly requestCanceled: Event<ODataVirtualCollectionView, EventArgs>;
|
|
616
|
+
/**
|
|
617
|
+
* Raises the {@link requestCanceled} event.
|
|
618
|
+
*/
|
|
619
|
+
onRequestCanceled(e?: EventArgs): void;
|
|
620
|
+
/**
|
|
621
|
+
* {@link ODataVirtualCollectionView} requires {@link pageOnServer} to be set to true.
|
|
622
|
+
*/
|
|
623
|
+
pageOnServer: boolean;
|
|
624
|
+
/**
|
|
625
|
+
* {@link ODataVirtualCollectionView} requires {@link sortOnServer} to be set to true.
|
|
626
|
+
*/
|
|
627
|
+
sortOnServer: boolean;
|
|
628
|
+
/**
|
|
629
|
+
* {@link ODataVirtualCollectionView} requires {@link filterOnServer} to be set to true.
|
|
630
|
+
*/
|
|
631
|
+
filterOnServer: boolean;
|
|
632
|
+
/**
|
|
633
|
+
* {@link ODataVirtualCollectionView} requires {@link canGroup} to be set to false.
|
|
634
|
+
*/
|
|
635
|
+
canGroup: boolean;
|
|
636
|
+
_performRefresh(): void;
|
|
637
|
+
_getReadParams(nextLink?: string): any;
|
|
638
|
+
_storeItems(items: any[], append: boolean): void;
|
|
639
|
+
_performSetWindow(start: number, end: number): void;
|
|
640
|
+
private _fetchSize;
|
|
641
|
+
}
|