new to birt question

Options
froster
edited February 11, 2022 in Analytics #1
Hello all, I am new to Birt. I have an array of objects and I have to display them in a table in birt, one row for one object, and each column is a field for that object.

Thanks very much!

Comments

  • froster
    edited December 31, 1969 #2
    Options
    actually all I want is to write script to the data element to freely display from an Array, rather than bind the table to a dataset. Is it doable?

    Thank you!
  • JMaleski
    edited December 31, 1969 #3
    Options
    I believe that table must be bound to a data set in order to display the information that you are describing.
  • Virgil Dodson
    Virgil Dodson E admin
    edited December 31, 1969 #4
    Options
    Hi froster,<br />
    <br />
    Displaying your array of Java objects is quite easy with the Scripted Data Source. With this approach, you write some script in the 'open' method to instantiate your objects... and then fill your dataset in the fetch method. As long as you return 'true' the data will be requested again... otherwise it will stop asking.<br />
    <br />
    open method example:<br />
    favoritesClass = new Packages.SimpleClass();<br />
    favorites = favoritesClass.readData();<br />
    totalrows = favorites.size();<br />
    currentrow = 0;<br />
    <br />
    fetch method example:<br />
    if( currentrow >= totalrows ){<br />
    return( false );<br />
    }<br />
    var favrow = favorites.get(currentrow);<br />
    <br />
    var Customer = favrow[0];<br />
    var Favorite = favrow[1];<br />
    var Color = favrow[2];<br />
    <br />
    row["Customer"]=Customer;<br />
    row["Favorite"]=Favorite;<br />
    row["Color"]=Color<br />
    currentrow = currentrow + 1;<br />
    return ( true );<br />
    <br />
    I uploaded a simple example into the DevShare area of this site at:<br />
    <a class='bbc_url' href='http://www.birt-exchange.com/modules/wfdownloads/singlefile.php?cid=2&lid=255'>http://www.birt-exchange.com/modules/wfdownloads/singlefile.php?cid=2&lid=255</a><br />
    <br />
    Based on your second question, you may also be interested in another example located at:<br />
    <a class='bbc_url' href='http://www.birt-exchange.com/modules/wfdownloads/singlefile.php?cid=2&lid=117'>http://www.birt-exchange.com/modules/wfdownloads/singlefile.php?cid=2&lid=117</a><br />
    <br />
    This second example uses a JDBC datasource... but shows how to dynamically create columns in a table at runtime. A combination of these two examples may be what you are looking for.
    Warning No formatter is installed for the format ipb