Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Is possible to create a data Set using JAVASCRIPT ?
Nathaniel
Hello.
I am a newbie in BIRT and I would like to know if is possible to create a dataset using a JAVASCRIPT ? The idea of this is to make my report very general and it will create a report based on the QUERY that is passed in the parameter.
In addition to the dataset, how could I create columns based on the query ? Could you provide me some documentations or links on how to go about it ?
Million thanks in advance for your support.
best regards.
Find more posts tagged with
Comments
JasonW
Yes this is possible. The entire report can be created in the beforeFactory event. Take a look at the attached example. It calls the de api in the beforeFactory script.
Jason
Nathaniel
Jason,
Thank you very much for the sample report. I have executed the report and it works. However, could you give me an example how it would work with a SELECT statement ?
Let us say, that I have the following query will be passed thru the parameter:
QUERY: SELECT name,address,age,bday FROM TEST;
Could you also illustrate how could I determine the number of columns to be created in the report ?
My idea here is to have the users select their own columns to be printed on the report. This means that the report would not know wheter the column to be displayed is of type INTEGER or STRING.
Do you think this is still possible with JAVASCRIPT ?
Again, thank you very much in advance for your prompt reply.
nathaniel
JasonW
I think it is still possible but you are going to have to split the sql string between select and from and then split on "," this should give you an array of the number of columns. The only issue you will have is knowing which column types to use. For that you may want to have a predefined array of column types for each name.
You may better off setting up a full report and dropping items they do not want. Take a look at this example.
Jason
Nathaniel
Dear Jason,
Thank you very much for your usual prompt reply. However, I did not quite understand the first sentence.
What do you mean by the following:
to have to split the sql string between select and from and then split on "," this should give you an array of the number of columns.
I did not quite understand this line.
thank you very much.
Nathaniel.
JasonW
What I meant is that you will have to use some javascript string functions to parse the query, cutting out the section of the string that represents the select clause and then split that string into the number of columns you have.
Jason