|
Re: Data Set scripting [message #507796 is a reply to message #507792] |
Thu, 14 January 2010 17:16 |
|
Klaus,
The best approach here is to add a computed column to the dataset and
put script in the expression. For example assume I have column that
returns a string and I want to chop the first couple of letters off the
string. I would add a computed column that has an expression that trims
the desired column value.
Jason
Klaus Meisl wrote:
> Hey,
> i got a Data Set which is not that perfect i need.
> So i want to get the Data, iterate through it and modify some of the
> results (columns) per script. How do i get the data? Which event
> (beforeClose, onFetch...) do i have to choose? Is it possible to add a
> column through scripting?
> I searched the internet but didn't find relevant information. Perhaps
> you can give me a hint.
> Thanks.
|
|
|
|
Re: Data Set scripting [message #508000 is a reply to message #507801] |
Fri, 15 January 2010 09:06 |
|
Klaus,
You are correct this will be hard with a computed column, but you should
be able to do it in the bound column expression when you are ready to
print the data. If you would like an example of how to do that stub out
the data(or sample data) into a text file and email it to me at
jasonweathersby at windstream.net.
Jason
Klaus Meisl wrote:
> Hey Jason,
>
> it's not that easy ;)
>
> Let's assume i have 2 columns with numbers and text
>
> SequenceNr SubItemYesNo Text
> 1 0 item1
> 2 0 item2
> 3 1 subitem #1 of 2
> 4 1 subitem #2 of 2
> 5 0 item5
> and so on...
>
> Now i want to display it in a table this way:
>
> 1 item1
> 2 item2
> 2.1 subitem #1 of 2
> 2.2 subitem #2 of 2
> 3 item5
>
> so you see, it doesn't work using SequenceNr as data. I can't change the
> data model... I would have to check every row if SubItemYesNo is 1 and
> then take the last SequenceNr where SubItemYesNo is 0... and raise this
> number if SubItemYesNo gets 0 again
>
> Thanks for your effort.
>
>
>
> Am 14.01.10 18:17, schrieb Jason Weathersby:
>> Klaus,
>>
>> The best approach here is to add a computed column to the dataset and
>> put script in the expression. For example assume I have column that
>> returns a string and I want to chop the first couple of letters off the
>> string. I would add a computed column that has an expression that trims
>> the desired column value.
>>
>> Jason
>>
>> Klaus Meisl wrote:
>>> Hey,
>>> i got a Data Set which is not that perfect i need.
>>> So i want to get the Data, iterate through it and modify some of the
>>> results (columns) per script. How do i get the data? Which event
>>> (beforeClose, onFetch...) do i have to choose? Is it possible to add a
>>> column through scripting?
>>> I searched the internet but didn't find relevant information. Perhaps
>>> you can give me a hint.
>>> Thanks.
>
|
|
|
Re: Data Set scripting [message #508227 is a reply to message #508000] |
Sun, 17 January 2010 21:25 |
Klaus Meisl Messages: 90 Registered: July 2009 |
Member |
|
|
Jason,
what should this text file contain? Should it have a special structure?
You could use the example i gave!?
Am 15.01.10 15:06, schrieb Jason Weathersby:
> Klaus,
>
> You are correct this will be hard with a computed column, but you should
> be able to do it in the bound column expression when you are ready to
> print the data. If you would like an example of how to do that stub out
> the data(or sample data) into a text file and email it to me at
> jasonweathersby at windstream.net.
>
> Jason
>
> Klaus Meisl wrote:
>> Hey Jason,
>>
>> it's not that easy ;)
>>
>> Let's assume i have 2 columns with numbers and text
>>
>> SequenceNr SubItemYesNo Text
>> 1 0 item1
>> 2 0 item2
>> 3 1 subitem #1 of 2
>> 4 1 subitem #2 of 2
>> 5 0 item5
>> and so on...
>>
>> Now i want to display it in a table this way:
>>
>> 1 item1
>> 2 item2
>> 2.1 subitem #1 of 2
>> 2.2 subitem #2 of 2
>> 3 item5
>>
>> so you see, it doesn't work using SequenceNr as data. I can't change
>> the data model... I would have to check every row if SubItemYesNo is 1
>> and then take the last SequenceNr where SubItemYesNo is 0... and raise
>> this number if SubItemYesNo gets 0 again
>>
>> Thanks for your effort.
>>
>>
>>
>> Am 14.01.10 18:17, schrieb Jason Weathersby:
>>> Klaus,
>>>
>>> The best approach here is to add a computed column to the dataset and
>>> put script in the expression. For example assume I have column that
>>> returns a string and I want to chop the first couple of letters off the
>>> string. I would add a computed column that has an expression that trims
>>> the desired column value.
>>>
>>> Jason
>>>
>>> Klaus Meisl wrote:
>>>> Hey,
>>>> i got a Data Set which is not that perfect i need.
>>>> So i want to get the Data, iterate through it and modify some of the
>>>> results (columns) per script. How do i get the data? Which event
>>>> (beforeClose, onFetch...) do i have to choose? Is it possible to add a
>>>> column through scripting?
>>>> I searched the internet but didn't find relevant information. Perhaps
>>>> you can give me a hint.
>>>> Thanks.
>>
|
|
|
Re: Data Set scripting [message #508610 is a reply to message #508227] |
Tue, 19 January 2010 15:54 |
|
Klaus,
I took that data and made a scripted dataset out of it.
I then created a table with the scripted dataset. I added a new column
and data item with the following expression:
if( dataSetRow["subitem"] == 1 ){
relsubseq++;
relseq+"."+relsubseq;
}else{
relsubseq=0;
relseq++;
relseq+"";
}
in the table's onprepare script I put:
relseq=0;
relsubseq=0;
This produced what you wanted. Take a look at the attached example.
Jason
<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.20"
id="1">
<property name="createdBy">Eclipse BIRT Designer Version
2.5.1.v20090903 Build <2.5.1.v20090917-1447></property>
<property name="units">in</property>
<property name="iconFile">/templates/blank_report.gif</property>
<property name="bidiLayoutOrientation">ltr</property>
<data-sources>
<script-data-source name="Data Source" id="7"/>
</data-sources>
<data-sets>
<script-data-set name="Data Set" id="8">
<list-property name="resultSetHints">
<structure>
<property name="position">0</property>
<property name="name">seqn</property>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="position">1</property>
<property name="name">subitem</property>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">txt</property>
<property name="dataType">string</property>
</structure>
</list-property>
<list-property name="columnHints">
<structure>
<property name="columnName">seqn</property>
</structure>
<structure>
<property name="columnName">subitem</property>
</structure>
<structure>
<property name="columnName">txt</property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">seqn</property>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">subitem</property>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">txt</property>
<property name="dataType">string</property>
</structure>
</list-property>
</structure>
<property name="dataSource">Data Source</property>
<method name="open"><![CDATA[i=0;
sourcedata = new Array( new Array(3),
new Array(3),
new Array(3),
new Array(3),
new Array(3));
sourcedata[0][0] = 1;
sourcedata[0][1] = 0;
sourcedata[0][2] = "item1";
sourcedata[1][0] = 2;
sourcedata[1][1] = 0;
sourcedata[1][2] = "item2";
sourcedata[2][0] = 3;
sourcedata[2][1] = 1;
sourcedata[2][2] = "subitem #1 of 2";
sourcedata[3][0] = 4;
sourcedata[3][1] = 1;
sourcedata[3][2] = "subitem #2 of 2";
sourcedata[4][0] = 5;
sourcedata[4][1] = 0;
sourcedata[4][2] = "item5";]]></method>
<method name="fetch"><![CDATA[if ( i < 5 )
{
row["seqn"] = sourcedata[i][0];
row["subitem"] = sourcedata[i][1];
row["txt"]= sourcedata[i][2];
i++;
return true;
}
return false;]]></method>
</script-data-set>
</data-sets>
<styles>
<style name="report" id="4">
<property name="fontFamily">sans-serif</property>
<property name="fontSize">10pt</property>
</style>
<style name="crosstab" id="5">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
<style name="crosstab-cell" id="6">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
</styles>
<page-setup>
<simple-master-page name="Simple MasterPage" id="2">
<page-footer>
<text id="3">
<property name="contentType">html</property>
<text-property
name="content"><![CDATA[<value-of>new Date()</value-of>]]></text-property>
</text>
</page-footer>
</simple-master-page>
</page-setup>
<body>
<table id="9">
<property name="dataSet">Data Set</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">seqn</property>
<text-property name="displayName">seqn</text-property>
<expression
name="expression">dataSetRow["seqn"]</expression>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="name">subitem</property>
<text-property
name="displayName">subitem</text-property>
<expression
name="expression">dataSetRow["subitem"]</expression>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="name">txt</property>
<text-property name="displayName">txt</text-property>
<expression
name="expression">dataSetRow["txt"]</expression>
<property name="dataType">string</property>
</structure>
<structure>
<property name="name">newseq</property>
<text-property
name="displayName">newseq</text-property>
<expression name="expression" type="javascript">if(
dataSetRow["subitem"] == 1 ){
relsubseq++;
relseq+"."+relsubseq;
}else{
relsubseq=0;
relseq++;
relseq+"";
}</expression>
<property name="dataType">string</property>
</structure>
</list-property>
<method name="onPrepare"><![CDATA[relseq=0;
relsubseq=0;]]></method>
<column id="34"/>
<column id="28"/>
<column id="30"/>
<header>
<row id="10">
<cell id="31">
<label id="36">
<text-property name="text">Calculated
Seq</text-property>
</label>
</cell>
<cell id="11">
<label id="12">
<text-property name="text">seqn</text-property>
</label>
</cell>
<cell id="15">
<label id="16">
<text-property name="text">txt</text-property>
</label>
</cell>
</row>
</header>
<detail>
<row id="17">
<cell id="32">
<data id="35">
<property
name="resultSetColumn">newseq</property>
</data>
</cell>
<cell id="18">
<data id="19">
<property
name="resultSetColumn">seqn</property>
</data>
</cell>
<cell id="22">
<data id="23">
<property name="resultSetColumn">txt</property>
</data>
</cell>
</row>
</detail>
<footer>
<row id="24">
<cell id="33"/>
<cell id="25"/>
<cell id="27"/>
</row>
</footer>
</table>
</body>
</report>
Klaus Meisl wrote:
> Jason,
> what should this text file contain? Should it have a special structure?
> You could use the example i gave!?
>
>
> Am 15.01.10 15:06, schrieb Jason Weathersby:
>> Klaus,
>>
>> You are correct this will be hard with a computed column, but you should
>> be able to do it in the bound column expression when you are ready to
>> print the data. If you would like an example of how to do that stub out
>> the data(or sample data) into a text file and email it to me at
>> jasonweathersby at windstream.net.
>>
>> Jason
>>
>> Klaus Meisl wrote:
>>> Hey Jason,
>>>
>>> it's not that easy ;)
>>>
>>> Let's assume i have 2 columns with numbers and text
>>>
>>> SequenceNr SubItemYesNo Text
>>> 1 0 item1
>>> 2 0 item2
>>> 3 1 subitem #1 of 2
>>> 4 1 subitem #2 of 2
>>> 5 0 item5
>>> and so on...
>>>
>>> Now i want to display it in a table this way:
>>>
>>> 1 item1
>>> 2 item2
>>> 2.1 subitem #1 of 2
>>> 2.2 subitem #2 of 2
>>> 3 item5
>>>
>>> so you see, it doesn't work using SequenceNr as data. I can't change
>>> the data model... I would have to check every row if SubItemYesNo is 1
>>> and then take the last SequenceNr where SubItemYesNo is 0... and raise
>>> this number if SubItemYesNo gets 0 again
>>>
>>> Thanks for your effort.
>>>
>>>
>>>
>>> Am 14.01.10 18:17, schrieb Jason Weathersby:
>>>> Klaus,
>>>>
>>>> The best approach here is to add a computed column to the dataset and
>>>> put script in the expression. For example assume I have column that
>>>> returns a string and I want to chop the first couple of letters off the
>>>> string. I would add a computed column that has an expression that trims
>>>> the desired column value.
>>>>
>>>> Jason
>>>>
>>>> Klaus Meisl wrote:
>>>>> Hey,
>>>>> i got a Data Set which is not that perfect i need.
>>>>> So i want to get the Data, iterate through it and modify some of the
>>>>> results (columns) per script. How do i get the data? Which event
>>>>> (beforeClose, onFetch...) do i have to choose? Is it possible to add a
>>>>> column through scripting?
>>>>> I searched the internet but didn't find relevant information. Perhaps
>>>>> you can give me a hint.
>>>>> Thanks.
>
|
|
|
Powered by
FUDForum. Page generated in 0.03812 seconds