new FormatConditionalAppearances(oPivot)
The FormatConditionalAppearances object holds the conditional-formats to apply on the pivot control. For instance, you can change the visual-appearance for positive values only. The FormatConditionalAppearances / GetFormatConditionalAppearances() method returns the control's format-appearances that defines the visual-appearance to apply on pivot-columns, based on conditions.
By default, the FormatConditionalAppearances collection contains the following objects:
- "negative", to show negative-numbers in red
- "positive", to show positive-numbers in green
Parameters:
| Name | Type | Description |
|---|---|---|
oPivot |
Pivot | Indicates an object of Pivot type that owns the collection. |
Example
The following sample shows the 0-cells in black and white:
oPivot.FormatConditionalAppearances.Add(
{
key: "zero",
shape: {fillColor: "black",tfi: {fgColor: "white"}},
expression: "value = 0"
})
Members
(readonly) Count :number
The Count property returns the number of FormatOptions objects within the collection. The FormatOptions object defines the conditional formats that can be applied to the pivot columns, pivot rows, and total/subtotal fields in the pivot table. The conditional formats are applied based on rules defined by the user, allowing for dynamic formatting of the pivot table based on specific conditions. The Add, Remove and Clear methods affect the count of formats within the collection. The Count property can be used to iterate through all formats within the collection. The Item method can be used to access a specific format within the collection. The FormatConditionalAppearances.forEach() method enumerates the FormatOptions objects within the current collection. By default, the FormatConditionalAppearances collection contains two conditional formats: "negative" to show negative-numbers in red, and "positive" to show positive-numbers in green.
Type:
- number
Example
0 {number}, there are no conditional formats defined in the collection
3 {number}, there are three conditional formats defined in the collection
Count
Methods
Add(oFormatOptions) → {FormatOptions}
The Add() method adds/updates the format based on its key. The FormatOptions object defines the conditional formats that can be applied to the pivot columns, pivot rows, and total/subtotal fields in the pivot table. The conditional formats are applied based on rules defined by the user, allowing for dynamic formatting of the pivot table based on specific conditions. The Item method can be used to access a specific format within the collection. The FormatConditionalAppearances.forEach() method enumerates the FormatOptions objects within the current collection.
Parameters:
| Name | Type | Description |
|---|---|---|
oFormatOptions |
object | Indicates an object of FormatOptions type that holds attributes of the format to add/replace. |
Returns:
Returns undefined (no key provided), or an the object being added of FormatOptions type that holds attributes of the format being added
- Type
- FormatOptions
Example
The following sample adds a conditional format to show the 0-cells in yellow:
Add(
{
key: "zero",
expression: "dbl(value) = 0",
shape:
{
fillColor: "yellow"
}
})
Add
Clear()
The Clear() method clears the FormatOptions objects within the collection. The Remove method can be used to remove a specific format within the collection, by key. The Count property can be used to iterate through all formats within the collection. The Item method can be used to access a specific format within the collection. The FormatConditionalAppearances.forEach() method enumerates the FormatOptions objects within the current collection. By default, the FormatConditionalAppearances collection contains two conditional formats: "negative" to show negative-numbers in red, and "positive" to show positive-numbers in green.
Example
oPivot.FormatConditionalAppearances.Clear(), clears all format-options from the control's format-conditional-appearances, to no longer show the negative-numbers in red, and the positive-numbers in green
Clear
Item(key) → {FormatOptions}
The Item() property gets the format based on the key. The Count property can be used to iterate through all formats within the collection. The FormatConditionalAppearances.forEach() method enumerates the FormatOptions objects within the current collection. By default, the FormatConditionalAppearances collection contains two conditional formats: "negative" to show negative-numbers in red, and "positive" to show positive-numbers in green.
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string | Specifies the key of the format to request. |
Returns:
Returns undefined (no format found), or an the object being added of FormatOptions type that holds attributes of the format being added
- Type
- FormatOptions
Example
oPivot.FormatConditionalAppearances.Item("negative"), gets the "negative" format-options from the control's format-conditional-appearances
Item
Remove(key) → {boolean}
The Remove() method removes the format giving its key. The Clear method can be used to remove all formats within the collection. The Count property can be used to iterate through all formats within the collection. The Item method can be used to access a specific format within the collection. By default, the FormatConditionalAppearances collection contains two conditional formats: "negative" to show negative-numbers in red, and "positive" to show positive-numbers in green.
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string | Specifies the key of the format to remove. |
Returns:
Returns true, if the key has been removed
- Type
- boolean
Example
oPivot.FormatConditionalAppearances.Remove("negative"), removes the "negative" format-options from the control's format-conditional-appearances, to no longer show the negative-numbers in red
Remove
forEach(callback, thisArg)
The forEach() method enumerates the FormatOptions objects within the current collection. The Count property counts the number of formats within the collection. The Item method can be used to access a specific format within the collection, by key. By default, the FormatConditionalAppearances collection contains two conditional formats: "negative" to show negative-numbers in red, and "positive" to show positive-numbers in green.
Parameters:
| Name | Type | Description |
|---|---|---|
callback |
callback | Indicates a function of callback(oFormatOptions) type, where
oFormatOptions {object}, indicates the format of FormatOptions type |
thisArg |
any | Specifies the value of "this" keyword during the callback. If missing it refers to the current collection. |
Example
The following sample enumerates all format-conditional-appearances within the control, and displays their keys:
oPivot.FormatConditionalAppearances.forEach(function(element, index)
{
console.log(exontrol.ToString.Quote(element));
})
forEach