ConditionalFormats class (Pivot)

ConditionalFormats(oPivot)

new ConditionalFormats(oPivot)

The ConditionalFormats object holds a collection of ConditionalFormat type. The conditional formatting feature allows you to apply formats to a cell or range of cells, and have that formatting change depending on the value of the cell or the value of a formula. Use the Pivot.ConditionalFormats method to get the control's conditional formats. The Shape property defines the format to apply when the condition is met, and the Expression property defines the condition as a string expression to evaluate. For instance, the expression can be "value > 100" to check whether the cell's value is greater than 100. The conditional format will be applied on cells that meet the condition defined by the expression. The conditional formats are evaluated in order, and if more than one conditional format meets the condition for a specific cell, all these conditional formats will be applied on that cell. Use the Add() method of this object to create and add new conditional formats into the control.
Parameters:
Name Type Description
oPivot Pivot Indicates an object of Pivot type that owns the collection.

Members

(readonly) Count :number

The Count property returns the number of conditional formats within the collection. The Add and Remove methods update this property automatically. The Item() method can be used to get a specific conditional format by index, key or reference, while the Remove() method can be used to remove a single conditional format by index, key or reference, and the RemoveRange() method can be used to remove multiple-conditional formats at once. The Clear() method can be used to remove all conditional formats of the control.
Type:
  • number
Example
The following statements are equivalents:

 oPivot.ConditionalFormats.GetCount(), counts the conditional formats within the collection
 oPivot.ConditionalFormats.Count, counts the conditional formats within the collection

where oPivot is an object of Pivot type
Count

Methods

Add(oConditionalFormatOpts) → {ConditionalFormat}

The Add() method creates and adds a new conditional format into the control. The new conditional format is created based on the options specified by the oConditionalFormatOpts parameter, and added into the collection of conditional formats. Once added, the new conditional format can be accessed by its index within the collection, or by its key if the Key property is specified within oConditionalFormatOpts parameter. The new conditional format can be removed by index, key or reference using the Remove() method, or all conditional formats can be removed at once using the Clear() method.
Parameters:
Name Type Description
oConditionalFormatOpts object Specifies the options to create the new conditional format as an object of ConditionalFormatOptions type. If no object is provided, it specifies the conditional format's caption.
Returns:
Returns the newly created conditional format, as an object of ConditionalFormat type
Type
ConditionalFormat
Example
oPivot.ConditionalFormats.Add(
 {
   expression: "%0 = 'ZL35'",
   shape: "red",
   applyTo: 0
 }, shows the cells of the first column with the caption ZL35 on red
 
 oPivot.ConditionalFormats.Add(
 {
   expression: "%1 contains '2'",
   shape: "green"
 }), shows each item in green, where the second-cell includes "2"

 oPivot.ConditionalFormats.Add(
 {
   expression: "%2 > 10",
   shape:
   {
     tfi:
     {
       bold: true
     }
   }
 }), bolds items, where values in the third-column are greater than 10
Add

Clear()

The Clear() method removes all conditional formats of the control and inits the control's scroll-bars. The RemoveRange() method can be used to remove multiple-conditional formats at once, while the Remove() method can be used to remove a single conditional format by index, key or reference.
Example
oPivot.ConditionalFormats.Clear(), removes all conditional formats of the control
Clear

Item(id) → {ConditionalFormat}

The Item() method gets the conditional format by index, key or reference. The index of the conditional formats is determined by their order within the collection, starting from 0. The key of the conditional format is specified by the Key property of the ConditionalFormat object. The Remove() method can be used to remove a single conditional format by index, key or reference, while the RemoveRange() method can be used to remove multiple-conditional formats at once. The Clear() method can be used to remove all conditional formats of the control.
Parameters:
Name Type Description
id any The id parameter could be any of the following:
  • id {number}, indicates a numeric value that defines the index of the conditional format to request
  • id {string}, specifies a string expression that defines the identifier/key of the conditional format to request
  • id {ConditionalFormat}, specifies the object reference to the conditional format to request for
Returns:
Returns null(the conditional format is not found), or an object of ConditionalFormat type, if the conditional formats collection contains the giving id.
Type
ConditionalFormat
Example
oPivot.ConditionalFormats.Item(0), gets the conditional format of index 0
 oPivot.ConditionalFormats.Item("myCF"), gets the conditional format of key
Item

Remove(id)

The Remove() method removes a conditional format from the collection. The id parameter could be the index of the conditional format within the collection, the key of the conditional format, or the reference to the conditional format itself. The RemoveRange() method can be used to remove multiple-conditional formats at once, while the Clear() method can be used to remove all conditional formats of the control. The Clear() method removes all conditional formats of the control.
Parameters:
Name Type Description
id any The id parameter could be any of the following:
  • id {number}, indicates a numeric value that defines the index of the conditional format to request
  • id {string}, specifies a string expression that defines the identifier/key of the conditional format to request
  • id {ConditionalFormat}, specifies the object reference to the conditional format to request for
Example
oPivot.ConditionalFormats.Remove(0), removes the conditional format of index 0
 oPivot.ConditionalFormats.Remove("myCF"), removes the conditional format of key "myCF"
Remove

RemoveRange(range)

The RemoveRange() method removes multiple-conditional formats at once. The range parameter could be a conditional format, an array of conditional formats, or an exontrol.Arr of conditional formats. The Remove() method can be used to remove a single conditional format by index, key or reference. The Clear() method can be used to remove all conditional formats of the control.
Parameters:
Name Type Description
range any Indicates a conditional format, an array [ConditionalFormat], or exontrol.Arr.
Example
oPivot.ConditionalFormats.RemoveRange( [oPivot.ConditionalFormats.Item(0), oPivot.ConditionalFormats.Item(1)] ), removes the conditional formats of index 0 and 2
RemoveRange