Set to open in the same window.
7. Do the same thing for the Amount column, except set the value of
rptprmSortorder to "price".
With that done, now you can reorder the report in time view, when the user clicks
on the date or the amount columns. With a little more logic developed in, you can
have the report do both ascending and descending sorts, and even have it refresh the
report without having to refresh the viewing page.
Scripted Data Source
One of the other things we can do with BIRT Scripting is to create a Data Source. In
the following example, we will create a simple report that will return 1 through 10
using a Scripted Data Source.
1. Create a new report called countOneToTen.rptdesign.
2. Right-click on the Data Sources section under the Data Explorer, and choose
Scripted Data Source as the type.
?° ?° ?° ?° ?°
Scripting and Event Handling
[ 250 ]
3. Create a new Data Set called dsCount.
4. A Dialog will pop up for the columns to return. Add one column called cnt
as type Integer.
5. The Script Editor will open up. In the Open Event, add the following code:
reportContext.setGlobalVariable("currentCount", 0);
6. In the fetch method, use the following code:
var currentCount = reportContext.getGlobalVariable("currentCount"
);
if (currentCount < 10)
{
currentCount++;
row["cnt"] = currentCount;
reportContext.
Pages:
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203