| Name | Type | Default |
|
source
# |
Object
|
null
|
Gets or sets pivot source adapter used to supply data to the pivot grid.
<template>
<JqxPivotGrid ref="myPivotGrid" :source="source" :autoResize="true" />
</template>
<script setup>
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
</script>
|
|
localization
# |
Object
|
null
|
Gets or sets the localization object used to localize the text elements of the pivot grid.
<template>
<JqxPivotGrid
ref="myPivotGrid"
:source="source"
:autoResize="true"
:localization="localization"
/>
</template>
<script setup>
import { ref } from 'vue';
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
const localization = ref({
sortascendingstring: 'Sortiere aufsteigend',
sortdescendingstring: 'Sortiere absteigend',
sortremovestring: 'Entferne Sortierung'
});
</script>
|
|
scrollBarsEnabled
# |
Boolean
|
true
|
Gets or sets whether the scrollbars of the pivot grid are enabled or disabled.
<template>
<JqxPivotGrid
ref="myPivotGrid"
:source="source"
:autoResize="true"
:scrollBarsEnabled="false"
/>
</template>
<script setup>
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
</script>
|
|
selectionEnabled
# |
Boolean
|
true
|
Gets or sets whether selection in the pivot grid is enabled or disabled.
<template>
<JqxPivotGrid ref="myPivotGrid" :source="source" :autoResize="true" :selectionEnabled="false" />
</template>
<script setup>
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
</script>
|
|
multipleSelectionEnabled
# |
Boolean
|
true
|
Gets or sets whether the multiple selection in the pivot grid is enabled or disabled.
<template>
<JqxPivotGrid
ref="myPivotGrid"
:source="source"
:autoResize="true"
:multipleSelectionEnabled="false"
/>
</template>
<script setup>
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
</script>
|
|
treeStyleRows
# |
Boolean
|
true
|
Gets or sets the rows of the pivot grid are displayed as a tree structure or using classic OLAP style.
<template>
<JqxPivotGrid ref="myPivotGrid" :source="source" :autoResize="true" :treeStyleRows="false" />
</template>
<script setup>
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
</script>
|
|
autoResize
# |
Boolean
|
false
|
Gets or sets if the size of pivot grid adjusts automatically to display the entire content.
<template>
<JqxPivotGrid ref="myPivotGrid" :source="source" :autoResize="true" />
</template>
<script setup>
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
</script>
|
|
itemsRenderer
# |
Function
|
null
|
Custom rendering function used to render the pivot rows and columns. The function should return a string which is valid HTML.
<template>
<JqxPivotGrid
ref="myPivotGrid"
:source="source"
:autoResize="true"
:itemsRenderer="itemsRenderer"
/>
</template>
<script setup>
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
function itemsRenderer(pivotItem) {
const backgroundColor = pivotItem.isColumn
? 'rgba(187, 232, 227, 255)'
: 'rgba(203, 254, 187, 255)';
return (
'<div style="background: ' +
backgroundColor +
'; width: calc(100% - 8px); height: calc(100% - 8px); padding: 4px;">' +
pivotItem.text +
'</div>'
);
}
</script>
|
|
cellsRenderer
# |
Function
|
null
|
Custom rendering function used to render the pivot cells. The function should return a string which is valid HTML.
<template>
<JqxPivotGrid
ref="myPivotGrid"
:source="source"
:autoResize="true"
:cellsRenderer="cellsRenderer"
/>
</template>
<script setup>
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
function cellsRenderer(pivotCell) {
const backgroundColor = 'rgba(253, 254, 207, 255)';
const cellText = pivotCell.value == 0 ? '' : pivotCell.formattedValue;
return (
'<div style="background: ' +
backgroundColor +
'; width: calc(100%-8px); height: 100%; padding: 4px; margin: 0px;">' +
cellText +
'</div>'
);
}
</script>
|
|
|
|
pivotitemexpanding
# |
Event
|
|
This event is triggered when a pivot item is expanding. You may use the event's cancel flag to stop further processing.
Code examples #
Bind to the pivotitemexpanding event of jqxPivotGrid.
<template>
<JqxPivotGrid
ref="myPivotGrid"
@pivotitemexpanding="onPivotitemexpanding($event)"
:source="source"
:autoResize="true"
/>
</template>
<script setup>
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
function onPivotitemexpanding(event) {
alert('do something...');
}
</script>
|
|
pivotitemexpanded
# |
Event
|
|
This event is triggered after a pivot item is expanded.
Code examples #
Bind to the pivotitemexpanded event of jqxPivotGrid.
<template>
<JqxPivotGrid
ref="myPivotGrid"
@pivotitemexpanded="onPivotitemexpanded($event)"
:source="source"
:autoResize="true"
/>
</template>
<script setup>
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
function onPivotitemexpanded(event) {
alert('do something...');
}
</script>
|
|
pivotitemcollapsing
# |
Event
|
|
This event is triggered when a pivot item is collapsing. You may use the event's cancel flag to stop further processing.
Code examples #
Bind to the pivotitemcollapsing event of jqxPivotGrid.
<template>
<JqxPivotGrid
ref="myPivotGrid"
@pivotitemcollapsing="onPivotitemcollapsing($event)"
:source="source"
:autoResize="true"
/>
</template>
<script setup>
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
function onPivotitemcollapsing(event) {
alert('do something...');
}
</script>
|
|
pivotitemcollapsed
# |
Event
|
|
This event is triggered after a pivot item is collapsed.
Code examples #
Bind to the pivotitemcollapsed event of jqxPivotGrid.
<template>
<JqxPivotGrid
ref="myPivotGrid"
@pivotitemcollapsed="onPivotitemcollapsed($event)"
:source="source"
:autoResize="true"
/>
</template>
<script setup>
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
function onPivotitemcollapsed(event) {
alert('do something...');
}
</script>
|
|
sortchanging
# |
Event
|
|
This event is triggered the sorting is about to change. You may use the event's cancel flag to stop further processing.
Code examples #
Bind to the sortchanging event of jqxPivotGrid.
<template>
<JqxPivotGrid
ref="myPivotGrid"
@sortchanging="onSortchanging($event)"
:source="source"
:autoResize="true"
/>
</template>
<script setup>
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
function onSortchanging(event) {
alert('do something...');
}
</script>
|
|
sortchanged
# |
Event
|
|
This event is triggered after the sorting order has changed.
Code examples #
Bind to the sortchanged event of jqxPivotGrid.
<template>
<JqxPivotGrid
ref="myPivotGrid"
@sortchanged="onSortchanged($event)"
:source="source"
:autoResize="true"
/>
</template>
<script setup>
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
function onSortchanged(event) {
alert('do something...');
}
</script>
|
|
sortremoving
# |
Event
|
|
This event is triggered the sorting is about to be removed. You may use the event's cancel flag to stop further processing.
Code examples #
Bind to the sortremoving event of jqxPivotGrid.
<template>
<JqxPivotGrid
ref="myPivotGrid"
@sortremoving="onSortremoving($event)"
:source="source"
:autoResize="true"
/>
</template>
<script setup>
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
function onSortremoving(event) {
alert('do something...');
}
</script>
|
|
sortremoved
# |
Event
|
|
This event is triggered after the sorting has been removed.
Code examples #
Bind to the sortremoved event of jqxPivotGrid.
<template>
<JqxPivotGrid
ref="myPivotGrid"
@sortremoved="onSortremoved($event)"
:source="source"
:autoResize="true"
/>
</template>
<script setup>
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
function onSortremoved(event) {
alert('do something...');
}
</script>
|
|
pivotitemselectionchanged
# |
Event
|
|
This event is triggered after the selection of a pivot item has changed.
Code examples #
Bind to the pivotitemselectionchanged event of jqxPivotGrid.
<template>
<JqxPivotGrid
ref="myPivotGrid"
@pivotitemselectionchanged="onPivotitemselectionchanged($event)"
:source="source"
:autoResize="true"
/>
</template>
<script setup>
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
function onPivotitemselectionchanged(event) {
alert('do something...');
}
</script>
|
|
pivotcellmousedown
# |
Event
|
|
This event is triggered on mousedown over a pivot grid cell. You may use the event's cancel flag to stop further processing.
Code examples #
Bind to the pivotcellmousedown event of jqxPivotGrid.
<template>
<JqxPivotGrid
ref="myPivotGrid"
@pivotcellmousedown="onPivotcellmousedown($event)"
:source="source"
:autoResize="true"
/>
</template>
<script setup>
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
function onPivotcellmousedown(event) {
alert('do something...');
}
</script>
|
|
pivotcellmouseup
# |
Event
|
|
This event is triggered on mouseup over a pivot grid cell. You may use the event's cancel flag to stop further processing.
Code examples #
Bind to the pivotcellmouseup event of jqxPivotGrid.
<template>
<JqxPivotGrid
ref="myPivotGrid"
@pivotcellmouseup="onPivotcellmouseup($event)"
:source="source"
:autoResize="true"
/>
</template>
<script setup>
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
function onPivotcellmouseup(event) {
alert('do something...');
}
</script>
|
|
pivotcellclick
# |
Event
|
|
This event is triggered on click over a pivot grid cell. You may use the event's cancel flag to stop further processing.
Code examples #
Bind to the pivotcellclick event of jqxPivotGrid.
<template>
<JqxPivotGrid
ref="myPivotGrid"
@pivotcellclick="onPivotcellclick($event)"
:source="source"
:autoResize="true"
/>
</template>
<script setup>
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
function onPivotcellclick(event) {
alert('do something...');
}
</script>
|
|
pivotcelldblclick
# |
Event
|
|
This event is triggered on double click over a pivot grid cell. You may use the event's cancel flag to stop further processing.
Code examples #
Bind to the pivotcelldblclick event of jqxPivotGrid.
<template>
<JqxPivotGrid
ref="myPivotGrid"
@pivotcelldblclick="onPivotcelldblclick($event)"
:source="source"
:autoResize="true"
/>
</template>
<script setup>
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
function onPivotcelldblclick(event) {
alert('do something...');
}
</script>
|
|
pivotitemmousedown
# |
Event
|
|
This event is triggered on mousedown over a pivot grid item. You may use the event's cancel flag to stop further processing.
Code examples #
Bind to the pivotitemmousedown event of jqxPivotGrid.
<template>
<JqxPivotGrid
ref="myPivotGrid"
@pivotitemmousedown="onPivotitemmousedown($event)"
:source="source"
:autoResize="true"
/>
</template>
<script setup>
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
function onPivotitemmousedown(event) {
alert('do something...');
}
</script>
|
|
pivotitemmouseup
# |
Event
|
|
This event is triggered on mouseup over a pivot grid item. You may use the event's cancel flag to stop further processing.
Code examples #
Bind to the pivotitemmouseup event of jqxPivotGrid.
<template>
<JqxPivotGrid
ref="myPivotGrid"
@pivotitemmouseup="onPivotitemmouseup($event)"
:source="source"
:autoResize="true"
/>
</template>
<script setup>
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
function onPivotitemmouseup(event) {
alert('do something...');
}
</script>
|
|
pivotitemclick
# |
Event
|
|
This event is triggered on click over a pivot grid item. You may use the event's cancel flag to stop further processing.
Code examples #
Bind to the pivotitemclick event of jqxPivotGrid.
<template>
<JqxPivotGrid
ref="myPivotGrid"
@pivotitemclick="onPivotitemclick($event)"
:source="source"
:autoResize="true"
/>
</template>
<script setup>
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
function onPivotitemclick(event) {
alert('do something...');
}
</script>
|
|
pivotitemdblclick
# |
Event
|
|
This event is triggered on double click over a pivot grid item. You may use the event's cancel flag to stop further processing.
Code examples #
Bind to the pivotitemdblclick event of jqxPivotGrid.
<template>
<JqxPivotGrid
ref="myPivotGrid"
@pivotitemdblclick="onPivotitemdblclick($event)"
:source="source"
:autoResize="true"
/>
</template>
<script setup>
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
function onPivotitemdblclick(event) {
alert('do something...');
}
</script>
|
|
|
| Name | Arguments | Return Type |
|
getInstance
# |
|
Object
|
Returns the instance of the pivot grid component
<template>
<JqxPivotGrid ref="myPivotGrid" :source="source" :autoResize="true" />
</template>
<script setup>
import { onMounted, ref } from 'vue';
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const myPivotGrid = ref(null);
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
onMounted(() => {
const value = myPivotGrid.value.getInstance();
});
</script>
|
|
refresh
# |
|
None
|
Refreshes the content of the pivot grid component
<template>
<JqxPivotGrid ref="myPivotGrid" :source="source" :autoResize="true" />
</template>
<script setup>
import { onMounted, ref } from 'vue';
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const myPivotGrid = ref(null);
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
onMounted(() => {
myPivotGrid.value.refresh();
});
</script>
|
|
getPivotRows
# |
|
Object
|
Return the pivot rows of the pivot grid
<template>
<JqxPivotGrid ref="myPivotGrid" :source="source" :autoResize="true" />
</template>
<script setup>
import { onMounted, ref } from 'vue';
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const myPivotGrid = ref(null);
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
onMounted(() => {
const value = myPivotGrid.value.getPivotRows();
});
</script>
|
|
getPivotColumns
# |
|
Object
|
Return the pivot columns of the pivot grid
<template>
<JqxPivotGrid ref="myPivotGrid" :source="source" :autoResize="true" />
</template>
<script setup>
import { onMounted, ref } from 'vue';
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const myPivotGrid = ref(null);
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
onMounted(() => {
const value = myPivotGrid.value.getPivotColumns();
});
</script>
|
|
getPivotCells
# |
|
Object
|
Return the pivot cells of the pivot grid
<template>
<JqxPivotGrid ref="myPivotGrid" :source="source" :autoResize="true" />
</template>
<script setup>
import { onMounted, ref } from 'vue';
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const myPivotGrid = ref(null);
const createPivotDataSource = function () {
// prepare sample data
const data = new Array();
const firstNames = ['Andrew', 'Nancy', 'Shelley', 'Regina', 'Yoshi'];
const lastNames = ['Fuller', 'Davolio', 'Burke', 'Murphy', 'Nagase'];
const productNames = [
'Black Tea',
'Green Tea',
'Caffe Espresso',
'Doubleshot Espresso',
'Caffe Latte'
];
const priceValues = ['2.25', '1.5', '3.0', '3.3', '4.5'];
for (let i = 0; i < 50; i++) {
const row = {};
const productindex = Math.floor(Math.random() * productNames.length);
const price = parseFloat(priceValues[productindex]);
const quantity = 1 + Math.round(Math.random() * 10);
row['firstname'] = firstNames[Math.floor(Math.random() * firstNames.length)];
row['lastname'] = lastNames[Math.floor(Math.random() * lastNames.length)];
row['productname'] = productNames[productindex];
row['price'] = price;
row['quantity'] = quantity;
row['total'] = price * quantity;
data[i] = row;
}
// create a data source and data adapter
const source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
const pivotDataSource = new jqx.pivot(dataAdapter, {
customAggregationFunctions: {
var: function (values) {
if (values.length <= 1) return 0;
// sample's mean
let mean = 0;
for (let i = 0; i < values.length; i++) mean += values[i];
mean /= values.length;
// calc squared sum
let ssum = 0;
for (let i = 0; i < values.length; i++) ssum += Math.pow(values[i] - mean, 2);
// calc the variance
const variance = ssum / values.length;
return variance;
}
},
pivotValuesOnRows: false,
rows: [{ dataField: 'firstname' }, { dataField: 'lastname' }],
columns: [{ dataField: 'productname' }],
filters: [
{
dataField: 'productname',
filterFunction: function (value) {
if (value == 'Black Tea' || value == 'Green Tea') return true;
return false;
}
}
],
values: [
{
dataField: 'price',
function: 'sum',
text: 'sum',
formatSettings: { prefix: '$', decimalPlaces: 2, align: 'right' }
},
{ dataField: 'price', function: 'count', text: 'count' },
{
dataField: 'quantity',
text: 'variance',
function: 'var',
formatSettings: { decimalPlaces: 2 }
}
]
});
return pivotDataSource;
};
let source = createPivotDataSource();
onMounted(() => {
const value = myPivotGrid.value.getPivotCells();
});
</script>
|