FormatAppearances class (Pivot)

FormatAppearances(oPivot)

new FormatAppearances(oPivot)

The FormatAppearances object holds the formats to apply on the pivot control. For instance, you can change the visual-appearance for all values to show within a pivot column. The FormatAppearances / GetFormatAppearances() method returns the control's format-appearances that defines the visual-appearance to apply on pivot-columns.

By default, the FormatAppearances collection contains the following objects:

  • "bold", to show the cells in bold
  • "italic", to show the cells in italics
  • "strikeout", to show the cells as strikeout
  • "underline", to underline the cells
Parameters:
Name Type Description
oPivot Pivot Indicates an object of Pivot type that owns the collection.
Example
oPivot.FormatAppearances.Add({key: "blue", shape: {fillColor: "rgba(0,0,255,0.5)"}}), adds "blue" to the control's format-appearances (right-click the control to show it), to show the cell's background in blue
oPivot.FormatAppearances.Add({key: "border", shape: {frameColor: "red"}}), adds "border" to the control's format-appearances (right-click the control to show it), to show a red-border arround the cell
oPivot.FormatAppearances.Add({key: "button", shape: "Button"}), adds "button" to the control's format-appearances (right-click the control to show it), to show the cells as buttons

Members

Count :number

The Count property returns the number of FormatOptions objects within the collection. 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. By default, the FormatAppearances collection contains 4 format-elements as explained in the constructor of FormatAppearances type.
Type:
  • number
Example
The following statementes are equivalent and display the number of FormatAppearances within the collection:

 oPivot.FormatAppearances.GetCount(), gets the number of FormatAppearances within the collection using the GetCount() method
 oPivot.FormatAppearances.Count, gets the number of FormatAppearances within the collection using the Count property

where oPivot is an object of Pivot type
Count

Methods

Add(oFormatOptions) → {FormatOptions}

The Add() method adds/updates the format based on its key. The format is added/updated only if it's valid. The Add() method returns the format being added/updated, or undefined if the format is not valid (e.g., no shape provided for FormatAppearances 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 new format to the control's format-appearances, to show the cell's background in yellow:

 oPivot.FormatAppearances.Add(
 {
   key: "yellow",
   shape: 
   {
     fillColor: "yellow"
   }
 })
Add

Clear()

The Clear() method clears the FormatOptions objects within the collection. The Clear() method removes all formats within the collection. The Item() method returns undefined for any key after calling the Clear() method. The Count property returns zero after calling the Clear() method.
Example
oPivot.FormatAppearances.Clear(), clears the formats within the control's format-appearances collection, to stop showing any visual-appearance based on formats
Clear

Item(key) → {FormatOptions}

The Item() property gets the format based on the key. The Item() method returns the format based on the key, or undefined if no format is found based on the key. The key is not case-sensitive, and leading/trailing spaces are ignored. For instance, if you add a format with key "blue", you can get it back using " blue ", or "BLUE" as a key.
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.FormatAppearances.Item("bold"), gets the "bold" format from the control's format-appearances, to show the cells in bold
Item

Remove(key) → {boolean}

The Remove() method removes the format giving its key. The Remove() method returns true if the format is removed, or false if no format is found based on the key. The key is not case-sensitive, and leading/trailing spaces are ignored. For instance, if you add a format with key "blue", you can remove it using " blue ", or "BLUE" as a key.
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.FormatAppearances.Remove("bold"), removes the "bold" format from the control's format-appearances, to stop showing the cells in bold
Remove