You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api/events/render-table-event.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,7 @@ The callback of the action takes the `config` object with the following paramete
48
48
-`field` - (optional) it's a string which is the id of a field
49
49
-`method` (string) - (optional) a method, if defined for a field in this column
50
50
-`methods` (array) - (optional) defines methods applied to fields in the hierarchical column in the tree mode
51
-
-`format` (string or object) - (required) [date format](/guides/custom-formatting/#custom-date-formatting) or [number format](/guides/custom-formatting/#custom-number-formatting)
51
+
-`format` (string or object) - (required) date format or number format (refer to [Applying formats to fields](/guides/working-with-data/#applying-formats-to-fields))
-`isTotal` (boolean) - (optional) defines whether it is a total column
54
54
-`area` (string) - (optional) an area where the column is rendered: "rows", "columns", "values"
@@ -59,7 +59,7 @@ The callback of the action takes the `config` object with the following paramete
59
59
-`value` (any) - (required) raw value, if a cell belongs to "columns" area
60
60
-`field` (string) - (required) a field, which value is displayed, if a cell belongs to "columns" area
61
61
-`method` (string) - (required) the field predicate, if a cell belongs to "columns" area and predicate is defined
62
-
-`format` (string or object) - [date format](/guides/custom-formatting/#custom-date-formatting) or [number format](/guides/custom-formatting/#custom-number-formatting)
62
+
-`format` (string or object) - date format or number format (refer to [Applying formats to fields](/guides/working-with-data/#applying-formats-to-fields))
63
63
-`footer` - (optional) a header label or an object with footer settings which are the same as the header settings
64
64
-`data` - (optional) an array of objects with data for the table; each object represents a row:
Copy file name to clipboardExpand all lines: docs/api/helpers/template.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,7 @@ For body cells the function takes the next parameters:
41
41
-`field` - (optional) it's a string which is the id of a field
42
42
-`method` (string) - (optional) a method, if defined for a field in this column
43
43
-`methods` (array) - (optional) defines methods applied to fields in the hierarchical column in the tree mode
44
-
-`format` (string or object) - (required) [date format](/guides/custom-formatting/#custom-date-formatting) or [number format](/guides/custom-formatting/#custom-number-formatting)
44
+
-`format` (string or object) - (required) date format or number format (please refer to [Applying formats to fields](/guides/working-with-data/#applying-formats-to-fields))
-`isTotal` (boolean) - (optional) defines whether it is a total column
47
47
-`area` (string) - (optional) an area where the column is rendered: "rows", "columns", "values"
@@ -52,7 +52,7 @@ For body cells the function takes the next parameters:
52
52
-`value` (any) - (required) raw value, if a cell belongs to "columns" area
53
53
-`field` (string) - (required) a field, which value is displayed, if a cell belongs to "columns" area
54
54
-`method` (string) - (required) the field predicate, if a cell belongs to "columns" area and predicate is defined
55
-
-`format` (string or object) - [date format](/guides/custom-formatting/#custom-date-formatting) or [number format](/guides/custom-formatting/#custom-number-formatting)
55
+
-`format` (string or object) - date format or number format (please refer to [Applying formats to fields](/guides/working-with-data/#applying-formats-to-fields))
56
56
57
57
For header cells the function parameters are the following:
58
58
@@ -66,7 +66,7 @@ For header cells the function parameters are the following:
66
66
-`value` (any) - (required) raw value, if a cell belongs to "columns" area
67
67
-`field` (string) - (required) a field, which value is displayed, if a cell belongs to "columns" area
68
68
-`method` (string) - (required) a field predicate, if a cell belongs to "columns" area and predicate is defined
69
-
-`format` (string or object) - (required) [date format](/guides/custom-formatting/#custom-date-formatting) or [number format](/guides/custom-formatting/#custom-number-formatting)
69
+
-`format` (string or object) - (required) date format or number format (please refer to [Applying formats to fields](/guides/working-with-data/#applying-formats-to-fields))
70
70
-`column` - (required) an object with column data (the same as for the body cell)
Copy file name to clipboardExpand all lines: docs/guides/localization.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -232,7 +232,7 @@ const table = new pivot.Pivot("#root", {
232
232
});
233
233
~~~
234
234
235
-
In case you need to set a custom format to a specific field, use the `format` parameter of the [`fields`](/api/config/fields-property) property. Refer to [Custom date formatting](/guides/custom-formatting/#custom-date-formatting).
235
+
In case you need to set a custom format to a specific field, use the `format` parameter of the [`fields`](/api/config/fields-property) property. Refer to [Applying formats to fields](/guides/working-with-data/#applying-formats-to-fields).
236
236
237
237
## Date and time format specification
238
238
@@ -268,7 +268,7 @@ To present the 20th of June, 2024 with the exact time as *2024-09-20 16:47:08.12
268
268
## Number formatting
269
269
270
270
By default, all fields with the number type are localized according to the locale (the value in the `lang` field of the locale). Pivot uses [`Intl.NumberFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat) specification. By default the fraction digits are limited to 3 and group separation is applied for the integer part.
271
-
In case you do not need to format specific fields with numeric values or need to set a custom format, use the the `format` parameter of the [`fields`](/api/config/fields-property) property. It can be either *false* to cancel formatting or an object with format settings (refer to [Custom number formatting](/guides/custom-formatting/#custom-number-formatting)).
271
+
In case you do not need to format specific fields with numeric values or need to set a custom format, use the the `format` parameter of the [`fields`](/api/config/fields-property) property. It can be either *false* to cancel formatting or an object with format settings (refer to [Applying formats to fields](/guides/working-with-data/#applying-formats-to-fields)).
Copy file name to clipboardExpand all lines: docs/guides/working-with-data.md
+96-6Lines changed: 96 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ This page describes how to aggregate data in Pivot. For the instructions about l
12
12
13
13
Use the [`fields`](/api/config/fields-property) property to add fields to the Pivot table. To add a new field, you should add a new object to the `fields` array.
14
14
15
-
### Example
15
+
Example:
16
16
17
17
~~~jsx
18
18
consttable=newpivot.Pivot("#root", {
@@ -28,11 +28,99 @@ const table = new pivot.Pivot("#root", {
28
28
});
29
29
~~~
30
30
31
+
## Applying formats to fields
32
+
33
+
For the description of default formatting of date and numeric fields, which depends on locale, refer to [Date formatting](/guides/localization/#date-formatting) and [Number formatting](/guides/localization/#number-formatting).
34
+
35
+
In case you need to set a custom format to a specific field, use the `format` parameter of the [`fields`](/api/config/fields-property) property. You can add text before and after numeric values using the `prefix` and `suffix` parameters. For example, to convert the value *12.345* to "12.35 EUR", `format` should contain the " EUR" suffix and maximumFractionDigits of 2:
By default, the format for numeric values limits fraction digits to 3 and applies group separation for the integer part. You can cancel formatting by setting `format` to *false* in the `field` configuration:
In the example below, fields like marketing, profit, and sales are identified as currency-related. A formatting object is applied to these fields with:
52
+
53
+
- prefix: "$" to display a dollar sign
54
+
-*minimumFractionDigits* and *maximumFractionDigits* set to 2 for consistent decimal formatting
55
+
56
+
~~~jsx
57
+
// Initialize pivot with pre-defined dataset and fields
To override the default locale-wide `dateFormat`, apply the `format` parameter of the [`fields`](/api/config/fields-property) property. Date format is a string, for example:
79
+
80
+
~~~jsx
81
+
constfields= [
82
+
{ id:"date", type:"date", format:"%M %d, %Y"},
83
+
];
84
+
~~~
85
+
86
+
In the example below we set the date format to "%d %M %Y %H:%i" for the "date" field only. The format displays day, full month name, year, hours, and minutes, e.g., "24 April 2025 14:30". In case you need to disable formatting of some fields, set the `format` parameter of the [`fields`](/api/config/fields-property) property to *false*.
You can create the Pivot structure using the [`config`](/api/config/config-property) property that also defines how data is aggregated. By default, it has no predefined values. You need to specify this property to define the configuration of the Pivot table, namely, which fields should be applied as columns and rows. The property also allows adding data aggregation methods to be applied to the fields. Here you can also add filters. Please, refer to the [`config`](/api/config/config-property) property description for details.
34
122
35
-
### Example
123
+
Example:
36
124
37
125
~~~jsx {4-18}
38
126
consttable=newpivot.Pivot("#root", {
@@ -202,7 +290,7 @@ To interrupt data rendering and prevent the component from hanging, you can limi
202
290
Limits are used for large dataset. Limits values are approximate values and do not show the exact values of the rows and columns.
203
291
:::
204
292
205
-
### Example
293
+
Example:
206
294
207
295
~~~jsx
208
296
consttable=newpivot.Pivot("#root", {
@@ -280,7 +368,7 @@ const defaultMethods = {
280
368
281
369
You can apply default methods using the `values` parameter of the [`config`](/api/config/config-property) property. See [Options for defining values](#options-for-defining-values) below.
282
370
283
-
### Example
371
+
Example:
284
372
285
373
~~~jsx
286
374
consttable=newpivot.Pivot("#root", {
@@ -311,7 +399,7 @@ You can define `values`in either of the two equally valid ways:
311
399
- option one is a string representing a data field ID: `operation(fieldID)`
312
400
- option two is an object containing the field ID and the method for data aggregation (both are required): `{ field: string, method: string }`
313
401
314
-
### Example
402
+
Example:
315
403
316
404
~~~jsx
317
405
values: [
@@ -574,6 +662,8 @@ In this snippet you can see how to apply custom maths operations:
Copy file name to clipboardExpand all lines: docs/news/whats-new.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ Released on ...
15
15
### New functionality
16
16
17
17
-[Ability to freeze columns on the right](/guides/configuration/#freezing-columns-on-the-right)
18
-
-[Numbers are formatted](/guides/localization/#number-formatting) according to the current locale with [a new possibility to define custom number formats within templates](/guides/custom-formatting) (for date and numeric fields) via `format` added to the [`fields`](/api/config/fields-property) property
18
+
-[Numbers are formatted](/guides/localization/#number-formatting) according to the current locale with [a new possibility to define custom number formats within templates](/guides/working-with-data/#applying-formats-to-fields) (for date and numeric fields) via `format` added to the [`fields`](/api/config/fields-property) property
19
19
-[Ability to style header and table cells](/guides/stylization/#cell-style) via the `cellStyle` parameter of the [`tableShape`](/api/config/tableshape-property) and [`headerShape`](/api/config/tableshape-property) properties
20
20
- Ability to insert HTML content to header and table cells via the [`pivot.template`](/api/helpers/template) helper by defining a template as a `cell` property of the header and column objects (table customization by intercepting the [render-table](/api/events/render-table-event) event)
21
21
-[Excel and CSV export settings enhanced](/guides/exporting-data):
0 commit comments