schema Object
The schema configuration of the PivotDataSource.
schema.axes Function|String
The field from the server response which contains the axes data of the columns and rows. Can be set to a function which is called to return the column and row axes data for the response.
Returns
Object
—The axes data of the columns and rows from the response.
The result has the following format and attributes.
{
columns:{ // columns axis data
tuples:[{
members:[{
children:[],
caption:"All",
name:"[Date].[Calendar].[All]",
levelName:"[Date].[Calendar].[(All)]",
levelNum:"0",
hasChildren:true,
hierarchy:"[Date].[Calendar]"
}, /*..other tuple members..*/]
}
/*..other tuples..*/
]
},
rows:{ //rows axis data
tuples:[{
members:[{
children:[],
caption:"All",
name:"[Customer].[Commute Distance].[All]",
levelName:"[Customer].[Commute Distance].[(All)]",
levelNum:"0",
hasChildren:true,
hierarchy:"[Customer].[Commute Distance]"
}, /*..other tuple members..*/]
},
/*..other tuples..*/
]
}
}
Example - specify the field which contains column and row axes as a string
<script>
var dataSource = new kendo.data.PivotDataSource({
transport: {
/* transport configuration */
},
schema: {
axes: "axes" // axes are returned in the "axes" field of the response
}
});
</script>
Example - set column and row axes data as a function
<script>
var dataSource = new kendo.data.PivotDataSource({
transport: {
/* transport configuration */
},
schema: {
axes: function(response) {
return response.axes; // axes are returned in the "axes" field of the response
}
}
});
</script>
schema.catalogs Function|String
The field from the server response which contains the list of catalogs that are available on the server. Can be set to a function which is called to return the schema information of the catalogs for the response. Executed during the schema discovery.
Returns
Array
—The catalogs schema from the response.
The result has the following format and attributes.
[{
"name":"Adventure Works Internet Sales Model"
}]
Example - specify the field which contains the catalogs schema information as a string
<script>
var dataSource = new kendo.data.PivotDataSource({
transport: {
/* transport configuration */
},
schema: {
catalogs: "catalogs" // catalogs information is returned in the "catalogs" field of the response
}
});
</script>
Example - set the schema information of the cubes as a function
<script>
var dataSource = new kendo.data.PivotDataSource({
transport: {
/* transport configuration */
},
schema: {
catalogs: function(response) {
return response.catalogs; // catalogs information are returned in the "catalogs" field of the response
}
}
});
</script>
schema.cubes Function|String
The field from the server response which contains the list of cubes that are available in the catalog. Can be set to a function which is called to return the schema information of the cubes for the response. Executed during the schema discovery.
Returns
Array
—The cubes schema from the response.
The result has the following format and attributes.
Example - specify the field which contains the schema information of the cubes as a string
<script>
var dataSource = new kendo.data.PivotDataSource({
transport: {
/* transport configuration */
},
schema: {
cubes: "cubes" // cubes information is returned in the "cubes" field of the response
}
});
</script>
Example - set the schema information of the cubes as a function
<script>
var dataSource = new kendo.data.PivotDataSource({
transport: {
/* transport configuration */
},
schema: {
cubes: function(response) {
return response.cubes; // cubes information are returned in the "cubes" field of the response
}
}
});
</script>
schema.cube Object
The cube declaration. If configured, this option will enable the client cube processing that is useful for binding to flat data.
Only applicable if client cube processing is used.
schema.cube.dimensions Object
A set of key/value pairs which specifies the field-dimension mapping that is available for processing dimensions. The key specifies the name of the field to which the dimension will be mapped.
The key has to match the column name that is used in the columns definition.
Example - define the cube dimensions
<script>
var dataSource = new kendo.data.PivotDataSource({
columns: ["ProductName" ],
rows: ["Category"],
data: [{ ProductName: "Chai", UnitPrice: 42, Cateogry: "Beverages" } ],
schema: {
cube: {
dimensions: {
ProductName: { caption: "All Products" },
Category: { caption: "All Cateogries" }
}
}
}
});
dataSource.fetch(function() {
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(dataSource.data(), dataSource.axes());
});
</script>
schema.cube.dimensions.dimensionName String
The name of the field which maps to the dimension.
schema.cube.dimensions.dimensionName.caption String
A user-friendly name of the dimension.
schema.cube.measures Object
A set of key/value pairs which specifies the available measures. The key specifies the name of measure.
The key has to match the measure name that is used in the measures definition of the PivotDataSource.
Example - define the cube measures which calculate the sum of the products price
<script>
var dataSource = new kendo.data.PivotDataSource({
columns: ["ProductName" ],
rows: ["Category"],
measures: ["Sum"],
data: [{ ProductName: "Chai", UnitPrice: 42, Cateogry: "Beverages" } ],
schema: {
cube: {
dimensions: {
ProductName: { caption: "All Products" },
Category: { caption: "All Cateogries" }
},
measures: {
"Sum": {
field: "UnitPrice",
format: "{0:c}",
aggregate: function(value, state, context) {
return (state.accumulator || 0) + value;
}
}
}
}
}
});
dataSource.fetch(function() {
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(dataSource.data(), dataSource.axes());
});
</script>
schema.cube.measures.measureName.field String
The field name whose value is used for calculations.
schema.cube.measures.measureName.format String
The format which will be applied to the calculated measure value.
schema.cube.measures.measureName.aggregate Function|String
The function that is used to aggregate the measure value.
The built-in aggregates are:
average
count
max
min
sum
Returns
Object
—The result of the calculation.
Parameters
# value Object
The value of the specified field of the currently processed record.
# state Object
The currently aggregated result of the function for already processed records.
state
uses a predefined field that is namedaccumulator
where the last aggregated result is preserved.
# context Object
The context for the current aggregate call. Includes the current data item and its index in the data.
{
dataItem: `data item`,
index: `data item index`
}
Example - specify a built-in "average" aggregate function
<script>
var dataSource = new kendo.data.PivotDataSource({
columns: ["ProductName" ],
rows: ["Category"],
measures: ["Sum"],
data: [{ ProductName: "Chai", UnitPrice: 42, Cateogry: "Beverages" } ],
schema: {
cube: {
dimensions: {
ProductName: { caption: "All Products" },
Category: { caption: "All Cateogries" }
},
measures: {
"Average": {
field: "UnitPrice",
aggregate: "average"
}
}
}
}
});
dataSource.fetch(function() {
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(dataSource.data(), dataSource.axes());
});
</script>
Example - specify an aggregate function for a value summing
<script>
var dataSource = new kendo.data.PivotDataSource({
columns: ["ProductName" ],
rows: ["Category"],
measures: ["Sum"],
data: [{ ProductName: "Chai", UnitPrice: 42, Cateogry: "Beverages" } ],
schema: {
cube: {
dimensions: {
ProductName: { caption: "All Products" },
Category: { caption: "All Cateogries" }
},
measures: {
"Average": {
field: "UnitPrice",
aggregate: function(value, state, context) {
return (state.accumulator || 0) + value;
}
}
}
}
}
});
dataSource.fetch(function() {
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(dataSource.data(), dataSource.axes());
});
</script>
schema.cube.measures.measureName.result Function
The function that will be called at the end of tuple aggregation.
If not defined, the
state.accumulator
value that is set in theaggregate
function will be used.
Returns
Object
—The result of the calculation.
Parameters
# state Object
The last aggregated result of the function for already processed records.
state
uses a predefined field namedaccumulator
where the last aggregated result is preserved.
Example - specify a result function that calculates the final value
<script>
var dataSource = new kendo.data.PivotDataSource({
columns: ["ProductName" ],
rows: ["Category"],
measures: ["Sum"],
data: [{ ProductName: "Chai", UnitPrice: 42, Cateogry: "Beverages" } ],
schema: {
cube: {
dimensions: {
ProductName: { caption: "All Products" },
Category: { caption: "All Cateogries" }
},
measures: {
"Average": {
field: "UnitPrice",
aggregate: function(value, state, context) {
if (!isNaN(value)) {
state.count = (state.count || 0) + 1;
return (state.accumulator || 0) + value;
} else {
return state.accumulator;
}
},
result: function(state) {
return state.accumulator / state.count
}
}
}
}
}
});
dataSource.fetch(function() {
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(dataSource.data(), dataSource.axes());
});
</script>
schema.data Function|String
The field from the server response which contains the data of the cells. Can be set to a function which is called to return the cell data for the response.
Returns
Array
—The cell data from the response.
The result has the following format and attributes.
[{
value:"1",
fmtValue:"1",
ordinal:0
},{
value:"42",
fmtValue:"$42.00",
ordinal:1
}, /*..*/]
Example - specify the field which contains the cell data as a string
<script>
var dataSource = new kendo.data.PivotDataSource({
transport: {
/* transport configuration */
},
schema: {
data: "data" // cells data are returned in the "data" field of the response
}
});
</script>
Example - set the cell data as a function
<script>
var dataSource = new kendo.data.PivotDataSource({
transport: {
/* transport configuration */
},
schema: {
data: function(response) {
return response.data; // cells data are returned in the "data" field of the response
}
}
});
</script>
schema.dimensions Function|String
The field from the server response which contains the dimensions schema information. Can be set to a function which is called to return the dimensions schema information for the response. Executed during the schema discovery.
Returns
Array
—The dimensions schema from the response.
The result has the following format and attributes.
[
{
"name":"Customer",
"caption":"Customer",
"uniqueName":"[Customer]",
"defaultHierarchy":"[Customer].[Commute Distance]",
"type":"3"
},
{
"name":"Date",
"caption":"Date",
"uniqueName":"[Date]",
"defaultHierarchy":"[Date].[Calendar]",
"type":"1"
}, /*..*/
]
Example - specify the field which contains the dimensions schema information as a string
<script>
var dataSource = new kendo.data.PivotDataSource({
transport: {
/* transport configuration */
},
schema: {
dimensions: "dimensions" // dimensions information is returned in the "dimensions" field of the response
}
});
</script>
Example - set the dimensions schema information as a function
<script>
var dataSource = new kendo.data.PivotDataSource({
transport: {
/* transport configuration */
},
schema: {
dimensions: function(response) {
return response.dimensions; // dimensions information are returned in the "dimensions" field of the response
}
}
});
</script>
schema.hierarchies Function|String
The field from the server response which contains the hierarchies schema information. Can be set to a function which is called to return the hierarchies schema information for the response. Executed during the schema discovery requests.
Returns
Array
—The cube hierarchies schema from the response.
The result has the following format and attributes.
[
{
"name":"Address Line 1",
"caption":"Address Line 1",
"uniqueName":"[Customer].[Address Line 1]",
"dimensionUniqueName":"[Customer]",
"origin":"2",
"defaultMember":"[Customer].[Address Line 1].[All]"
},
{
"name":"Address Line 2",
"caption":"Address Line 2",
"uniqueName":"[Customer].[Address Line 2]",
"dimensionUniqueName":"[Customer]",
"origin":"2",
"defaultMember":"[Customer].[Address Line 2].[All]"
},
/*..*/
]
Example - specify the field which contains hierarchies schema information as a string
<script>
var dataSource = new kendo.data.PivotDataSource({
transport: {
/* transport configuration */
},
schema: {
hierarchies: "hierarchies" // hierarchies schema information is returned in the "hierarchies" field of the response
}
});
</script>
Example - set hierarchies schema information as a function
<script>
var dataSource = new kendo.data.PivotDataSource({
transport: {
/* transport configuration */
},
schema: {
hierarchies: function(response) {
return response.hierarchies; // hierarchies information are returned in the "hierarchies" field of the response
}
}
});
</script>
schema.levels Function|String
The field from the server response which contains the levels schema information. Can be set to a function which is called to return the levels schema information for the response. Executed during the schema discovery.
Returns
Array
—The levels schema from the response.
The result has the following format and attributes.
[ { "name":"(all)", "caption":"(all)", "uniquename":"[customer].[address line 1].[(all)]", "dimensionuniquename":"[customer]", "orderingproperty":"(all)", "origin":"2", "hierarchyuniquename":"[customer].[address line 1]" }, { "name":"address line 1", "caption":"address line 1", "uniquename":"[customer].[address line 1].[address line 1]", "dimensionuniquename":"[customer]", "orderingproperty":"address line 1", "origin":"2", "hierarchyuniquename":"[customer].[address line 1]" }, /../ ]
Example - specify the field which contains the levels schema information as a string
<script>
var dataSource = new kendo.data.PivotDataSource({
transport: {
/* transport configuration */
},
schema: {
levels: "levels" // levels information is returned in the "levels" field of the response
}
});
</script>
Example - set the levels schema information as a function
<script>
var dataSource = new kendo.data.PivotDataSource({
transport: {
/* transport configuration */
},
schema: {
levels: function(response) {
return response.levels; // levels information are returned in the "levels" field of the response
}
}
});
</script>
schema.measures Function|String
The field from the server response which contains the measures schema information. Can be set to a function which is called to return the measures schema information for the response. Executed during the schema discovery.
Returns
Array
—The measures schema from the response.
The result has the following format.
[
{
"name":"Days Current Quarter to Date",
"caption":"Days Current Quarter to Date",
"uniqueName":"[Measures].[Days Current Quarter to Date]",
"aggregator":"0",
"groupName":"Date"
},
{
"name":"Days in Current Quarter",
"caption":"Days in Current Quarter",
"uniqueName":"[Measures].[Days in Current Quarter]",
"aggregator":"0",
"groupName":"Date"
},
/*..*/
]
Example - specify the field which contains the measures schema information as a string
<script>
var dataSource = new kendo.data.PivotDataSource({
transport: {
/* transport configuration */
},
schema: {
measures: "measures" // measures information is returned in the "measures" field of the response
}
});
</script>
Example - set the measures schema information as a function
<script>
var dataSource = new kendo.data.PivotDataSource({
transport: {
/* transport configuration */
},
schema: {
measures: function(response) {
return response.measures; // measures information are returned in the "measures" field of the response
}
}
});
</script>