In this blog entry, we review the ShieldUI DataSource schema definition.
Shield UI DataSource provides a series of schema settings that describe how the data is parsed and mapped into suitable JavaScript objects. The schema is a JavaScript object that is specified either through the schema setting during initilization, or using the schema property after the DataSource has been initialized:
Shield UI DataSource provides a series of schema settings that describe how the data is parsed and mapped into suitable JavaScript objects. The schema is a JavaScript object that is specified either through the schema setting during initilization, or using the schema property after the DataSource has been initialized:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
| var ds = new shield.DataSource( { schema: { //specifies the path to the data array in the result object after read() //can be a function accepting the result object and returning an array data: "result.data" , //specifies the path to the total item count in the result object after read() //can be a function accepting the result object and returning a number count: "result.count" , //specifies field types and maps fields to other field names fields: { productId: { //map data from the "id" field to a new "productId" field path: "id" , //convert data values to numbers type: "number" }, productName: { path: "name" }, launched: { path: "launchDate" , type: "date" }, discontinued: { type: "bool" } } } }); ds.read().then( function () { var dataView = ds.view; //dataView is an array of objects, where each object has a field "productId" //containing numeric values, "productName" containing strings, "launched" //containing Date objects and "discontinued" containing Boolean values }); |
Няма коментари:
Публикуване на коментар