Scripted Data Source "DESCRIBE EVENT"

seskersesker Junior Member
edited December 31, 1969 in Designing Analytics Reports
I am having a hard time finding and documentation on the Scripted Data Source Describe event. I need to dynamically add columns to a data source and to a table depending on some user defined criteria in our application. The user can add as many columns to a data set for display in the UI as they want.

From what I have read, the Describe event is for that specifically. Can anyone point me to any references on it's usage? I have searched for several hours and not found anything. I did find old examples of using DEAPI for doing that, or for using java for event handling -- but I want to keep everything in javascript if possible...

Thanks in advance...

Scott

Comments

  • seskersesker Junior Member
    edited December 31, 1969
    Also, how do I dynamically add a column to a table in a scripted datasource (i.e. javascript and which event?)
  • edited December 31, 1969
    Hi Scott,
    You can use dataSetMetaData.addColumn() to add columns in describe event of the data set. To add table columns you would write java script to the onPrepare event handler of your table. Here is a link that has an example:
    http://www.eclipse.org/forums/index.php?t=msg&goto=492448&;


    Ashwini

    Ashwini

    Follow me on Twitter
    Read my Blog BIRT Rocks!

  • seskersesker Junior Member
    edited September 1, 2010
    Are you referring to add a java class as an event handler? I would rather to it entirely in javascript in the report event handling scripts.

    Is there any docs on the that call, or what is available in the describe event? Is the addcolumn the same as the Java API? The problem is there is no documentation for the javascript calls and what is available in the various events (other than the autocomplete when you do something like: this.<eclipse gives you autocomplete>
  • edited December 31, 1969
    Hi Scott,
    I have attached an example that uses javascript in describe event handler to add columns. It uses addDataSetColumn() to add columns.
    To find out what is available in the event handler, I usually switch to Palette view and then use the objects from there. The auto suggest feature usually lets me know my options.
    In this particular case it did not suggest me all the functions and that is a bug. Feel free to report such bugs here:
    http://www.birt-exchange.org/org/resources/bug-reporting/
    I have already reported this issue so you don't have to.

    Ashwini

    Ashwini

    Follow me on Twitter
    Read my Blog BIRT Rocks!

  • LeaLea
    edited December 31, 1969
    Hi Ashwini,

    thanks for your example - it works perfectly. I tried to expand it for my own needs but ran into a problem. Maybe you could help again. I just added a line that creates a new object from a class that is my own (e.g.: var test = new Packages.examplePackages.ExampleClass() ). I don't even us it - just creating it. The preview via the properties (Properties->Preview Results) is still fine, but I also need the columns within the tree in the Data Explorer. This is always empty. If I remove the mentioned line, everything is fine again.

    Any hints?

    Thanks!
  • edited December 31, 1969
    Hi Lea,
    If you edit the data set and go to "output columns", here you can add new columns that will show up in the data set.

    Ashwini

    Ashwini

    Follow me on Twitter
    Read my Blog BIRT Rocks!

  • LeaLea
    edited December 31, 1969
    Hi Ashwini,

    thanks for your reply. Unfortunately this is not what I need. I still need to add the columns dynamically within the describe-event. But I need to read them from my own library.

    Thanks,

    Lea
  • edited December 31, 1969
    I am not sure if I have a correct understanding of your issue. Are you saying that you can use javascript to add columns dynamically but would like to use Java instead?

    Ashwini

    Follow me on Twitter
    Read my Blog BIRT Rocks!

  • LeaLea
    edited December 31, 1969


    I am not sure if I have a correct understanding of your issue. Are you saying that you can use javascript to add columns dynamically but would like to use Java instead?




    I'd like to use both. Within the fetch-event I'd like to use the addDataSetColumn but the string that is used comes from my own java-lib.



    This works:

    var list = ["Test", "Test2", "Test3", "Test4"];



    while (count < list.length){

    this.addDataSetColumn(list[count],"STRING");

    count++;

    }



    This does not work:



    var myVariable = new Packages.birt.Test();

    var list = ["Test", "Test2", "Test3", "Test4"];



    while (count < list.length){

    this.addDataSetColumn(list[count],"STRING");

    count++;

    }





    Within the preview both versions are ok, but the tree in the explorer does not show the columns in the second case. Although I did not even use "myVariable".
  • edited June 3, 2011
    Hi Lea,
    Try adding the following prefix to your script:
    importPackage( Packages.birt );
    Also make sure your java classes are available to BIRT engine:
    http://wiki.eclipse.org/BIRT/FAQ/Scripting#Q:_Where_do_I_have_to_put_my_classes_in_order_to_access_them_by_JavaScript.3F

    Let me know how that goes.

    Ashwini

    Ashwini

    Follow me on Twitter
    Read my Blog BIRT Rocks!

  • LeaLea
    edited December 31, 1969
    Hi,




    Let me know how that goes.




    I also tried your idea with the same result. The java classes I need here are "imported" as a project, and they must be available since it works within the preview, but not in the tree. Meanwhile I had to change my settings anyway and I started using the API to write the report/datasources anew. So need not to have a solution for this issue.



    But thanks a lot for your help!
Sign In or Register to comment.