Updating Pivot Tables with Partial Page Rendering

Using ADF Pivot Table Components 26-11 Figure 26–13 Sales Data Per Product Category Example 26–5 shows sample code that produces the required custom formats for the sales totals, but not for the stoplight formatting. The example includes the code for method expressions for both the dataFormat attribute and the headerFormat attribute of the dvt:pivotTable tag. If you want to include stoplight formatting in the pivot table, you might want to include the code from Example 26–6 . Example 26–5 Sample Code to Change Style and Text Style in a Pivot Table public CellFormat getDataFormatDataCellContext cxt { CellFormat cellFormat = new CellFormatnull, null, null; QDR qdr = cxt.getQDR; Obtain a reference to the product category column. Object productCateg = qdr.getDimMemberProductCategory; Obtain a reference to the product column. Object product = qdr.getDimMemberProductId; if productCateg = null productCateg.toString.equalsSales Total { cellFormat.setTextStylefont-weight:bold cellFormat.setStylebackground-color:C0C0C0; } else if product = null product.toString.equalsSales Total { cellFormat.setTextStylefont-weight:bold; cellFormat.setStylebackground-color:C0C0C0; } return cellFormat; } public CellFormat getHeaderFormatHeaderCellContext cxt { if cxt.getValue = null { String header = cxt.getValue.toString; if header.equalsSales Total { 26-12 Web User Interface Developers Guide for Oracle Application Development Framework return new CellFormatnull, background-color:C0C0C0, font-weight:bold; } } return null; }

26.9.4 How to Create Stoplight and Conditional Formatting in a Pivot Table

Stoplight and conditional formatting of the cells in a pivot table are examples of customizing the cell content. For this kind of customization, an application might prompt a user for a high value and a low value to be associated with the stoplight formatting. Generally three colors are used as follow: ■ Values equal to and above the high value are colored green to indicate they have no issues. ■ Values above the low value but below the high value are colored yellow to warn that they are below the high standard. ■ Values at or below the low value are colored red to indicate that they fall below the minimum acceptable level. Figure 26–13 shows data cells with stoplight formatting for minimum, acceptable, and below standards sales for States. Example 26–6 shows code that performs stoplight formatting in a pivot table that does not display totals. If you want to do stoplight formatting for a pivot table that displays totals, then you might want to combine the code from Example 26–5 which addresses rows with totals with the code for stoplight and conditional formatting. Example 26–6 Sample Code for Stoplight and Conditional Formatting public CellFormat getDataFormatDataCellContext cxt { Use low and high values provided by the application. double low = m_rangeValues.getMinimum.doubleValue 100; double high = m_rangeValues.getMaximum.doubleValue 100; CellFormat cellFormat = new CellFormatnull, null, null; Create stoplight format if isStoplightingEnabled { String color = null; Object value = cxt.getValue; if value = null value instanceof Number { double dVal = Numbervalue.doubleValue; if dVal = low { color = background-color: + ColorUtils.colorToHTMLm_belowColor + ;; } else if dVal low dVal = high { color = background-color: + ColorUtils.colorToHTMLm_goodColor + ;; } else if dVal high { color = background-color: + ColorUtils.colorToHTMLm_aboveColor + ;; }