Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » javascript to iterate through a dataset to find a value?
javascript to iterate through a dataset to find a value? [message #869998] Sat, 05 May 2012 15:35 Go to next message
manny is currently offline mannyFriend
Messages: 4
Registered: July 2009
Junior Member
I have a text element and through javascript I want to iterate the
dataset that is assigned to it to find a particular value.

Say I have dataset bound to the text element that is made up of

key value
a 1
b 2
c 3

I want to be able to iterate to find 'C' and then fetch the value 3
from that row.

to share, I don't know what the javascript should look like, but to
illustrate, I'm trying to do something like

answer = "default"
for (i = 0; i < row.maxrow;i++){

if ( row[i].getValue("value") == "a" ) {
answer = row[i].getValue("key")
}
}


I found a defect in bugzilla where others have requested similar
behavior but its been deferred.
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=202376)

OR......Is there some way I can accomplish this? Thanks again for the
help and apologies for my lack of knowing birt very well.
Re: javascript to iterate through a dataset to find a value? [message #870042 is a reply to message #869998] Sat, 05 May 2012 22:44 Go to previous messageGo to next message
manny is currently offline mannyFriend
Messages: 4
Registered: July 2009
Junior Member
To share...so found a way around this, I wrote javascript on event
onRender for a hidden table element. This allows me to secretly
traverse the table and search for what I want. Then I write the found
information to a global variable which I then can read from my text
field in the visible table that will display information. .

Seems a lot of work..but I'm moving forward. perhaps there is a better
way, if so I'd like to hear about it :D


On Sat, 05 May 2012 08:35:39 -0700, manny
<mannyfuf0fuz@xxxxxxxx> wrote:

>I have a text element and through javascript I want to iterate the
>dataset that is assigned to it to find a particular value.
>
>Say I have dataset bound to the text element that is made up of
>
>key value
>a 1
>b 2
>c 3
>
>I want to be able to iterate to find 'C' and then fetch the value 3
>from that row.
>
>to share, I don't know what the javascript should look like, but to
>illustrate, I'm trying to do something like
>
>answer = "default"
>for (i = 0; i < row.maxrow;i++){
>
> if ( row[i].getValue("value") == "a" ) {
> answer = row[i].getValue("key")
> }
>}
>
>
>I found a defect in bugzilla where others have requested similar
>behavior but its been deferred.
>(https://bugs.eclipse.org/bugs/show_bug.cgi?id=202376)
>
>OR......Is there some way I can accomplish this? Thanks again for the
>help and apologies for my lack of knowing birt very well.
Re: javascript to iterate through a dataset to find a value? [message #870321 is a reply to message #870042] Mon, 07 May 2012 16:05 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

This is probably similar to the way you did it but I use the onCreate
method on the detail row of a table to load up an array and then I can
use a simple expression to get any row/col. See attached.

Jason

On 5/5/2012 6:44 PM, manny wrote:
> To share...so found a way around this, I wrote javascript on event
> onRender for a hidden table element. This allows me to secretly
> traverse the table and search for what I want. Then I write the found
> information to a global variable which I then can read from my text
> field in the visible table that will display information. .
>
> Seems a lot of work..but I'm moving forward. perhaps there is a better
> way, if so I'd like to hear about it :D
>
>
> On Sat, 05 May 2012 08:35:39 -0700, manny
> <mannyfuf0fuz@xxxxxxxx> wrote:
>
>> I have a text element and through javascript I want to iterate the
>> dataset that is assigned to it to find a particular value.
>>
>> Say I have dataset bound to the text element that is made up of
>>
>> key value
>> a 1
>> b 2
>> c 3
>>
>> I want to be able to iterate to find 'C' and then fetch the value 3
>>from that row.
>>
>> to share, I don't know what the javascript should look like, but to
>> illustrate, I'm trying to do something like
>>
>> answer = "default"
>> for (i = 0; i< row.maxrow;i++){
>>
>> if ( row[i].getValue("value") == "a" ) {
>> answer = row[i].getValue("key")
>> }
>> }
>>
>>
>> I found a defect in bugzilla where others have requested similar
>> behavior but its been deferred.
>> (https://bugs.eclipse.org/bugs/show_bug.cgi?id=202376)
>>
>> OR......Is there some way I can accomplish this? Thanks again for the
>> help and apologies for my lack of knowing birt very well.
Previous Topic:Is possible to re-use the header and footer
Next Topic:BIRT 3.7.2: Unable to access the data from outer data set using row._outer<column-name>
Goto Forum:
  


Current Time: Thu Jan 23 06:23:05 GMT 2020

Powered by FUDForum. Page generated in 0.02106 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top