Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Altering Properties of Crosstab Grouping DataItem
PaulCooper
<p>I have a crosstab with three user selectable top groupings and three user selectable left groupings. I am using code to attempt to modify the formatting of the groupings based on the fields the user selects (in a set of parameters).<br><br>
I have the code like this:<br>
</p>
<pre class="_prettyXprint">
var groupingElement = reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("topGrouping1");
updateProperties("dataFormat", groupingElement.getProperty("numberFormat"), "###0{RoundingMode=HALF_DOWN}", "pattern")</pre>
<p>groupingElement finds the element in question and <strong>updateProperties</strong> using a function I wrote to modify the property. This function works perfectly well elsewhere in my report on a dynamically created label that get added to a table:<br>
</p>
<pre class="_prettyXprint">
var agg = elementFactory.newDataItem( null );
.
.
.
if(data_type == "Number") numFormat = updateProperties("dataFormat", agg.getProperty("numberFormat"), fieldInfo[8], "pattern");
.
.
.</pre>
<p>When I use it on an existing dataitem (topGrouping1) in the crosstab the object <strong>groupingElement.getProperty("numberFormat")</strong> is null even though you can see it has the numberFormat property through Eclipse BIRT GUI and I can see it in the cached properties of the dataElement sub-object when I view groupingElement variable in the debugger.<br><br>
Is this because it exists already and is there anyway to get or alter the property via a different route?</p>
<p> </p>
<p>Edit:<br>
Additional Info:<br><br>
1) updateProperties function<br>
The updateProperties function takes the following arguments:<br><br><strong>class:</strong> The name of the array of properties allowed<br><strong>properties object:</strong> A properties object<br><strong>value:</strong> This is either a value for the default property or a semi-colon delimited list of property name/value pairs.<br><strong>default property:</strong> The property to use if no property name is specified. (see value above)<br><br>
This function would to the properties object either set the default property with a single value or if the value is a delimited list work through each one and set all the properties given.<br><br>
2) I may be able to workround this problem by using the getStyle().<em>property_name</em> method but I would need to write an function that takes the property name and sets the appropriate property. This would be an ineligant way to do this.<br>
</p>
Find more posts tagged with
Comments
PaulCooper
<p>I solved this eventually. The "numberFormat", "dateTimeFormat" and "stringFormat" properties are null so I had to create them using the StructureFactory:</p>
<pre class="_prettyXprint">
var formatObj = StructureFactory.newFormatValue();</pre>
<p>Modify this newly created Property object and set the original property (e.g. "numberFormat", etc.) to be the new object along the lines of:</p>
<pre class="_prettyXprint">
function updateProperties(class, parentPropObj, propName, value, defaultProp)
{
var defP = defaultProp;
if (defP === null || defP === undefined)
{
.
.
.
if (["category", "pattern", "locale"].indexOf(defP) > -1)
{
if (parentPropObj.getProperty(propName) === null)
{
var formatObj = StructureFactory.newFormatValue();
if (defP == "pattern") formatObj.setProperty("category", "custom");
formatObj.setProperty(defP, value);
parentPropObj.setProperty(propName, formatObj);
}
else
{
var formatObj = parentPropObj.getProperty(propName);
if (defP == "pattern") formatObj.setProperty("category", "custom");
formatObj.setProperty(defP, value);
}
.
.
.</pre>
<p>Paul Cooper</p>