Access parameters outside ActiveReportsJs

Posted by: arian on 30 November 2023, 1:50 am EST

    • Post Options:
    • Link

    Posted 30 November 2023, 1:50 am EST - Updated 30 November 2023, 1:55 am EST

    I want to know if there is any way to execute custom Function on Preview click on ActiveReportsJs React.

    I need to manipulate data outside activereportsjs based on parameters set and then attach to activereportjs and open report.

    Is there any way to do this?

  • Posted 30 November 2023, 8:47 pm EST

    Hi Arian,

    The viewer has an event ‘reportLoaded’ which gets called when the report gets loaded after the ‘viewer.Load()’ method but before the parameters are passed into the report. However, this event receives the report JSON as an argument you can store this into a variable and then also handle the ‘documentLoaded’ event of the viewer which gets called when the parameters are passed into the report and the report document is loaded into the viewer.

    In the handler for the ‘documentLoaded’ event, you can use your report variable to get the various parameters and their values every time the report is loaded with a new parameter value.

    Please find attached a simple project implementing the same.

    Regards,

    Anand

    ParameterReport.zip

  • Posted 30 November 2023, 8:59 pm EST - Updated 1 December 2023, 2:28 am EST

    Hi Adnand,

    Thank you for your reply.

    I have one more question. Im writing here not to open new post.

    Lets assume we have a report like the one below.

    we have one dataset with the data

    category, subCategory, amount, totalAmount, itemNo(this is integer starting from 1)

    Now i want to group by category and subCataegory, but to display amount and totalAmount of biggest itemNo and then in subCategory total to sum totalAmount for each subCategory (also here to take all biggest itemNo for each subCategory)

    and then total of all categories again for each subCategory with biggest itemNo.

    I managed displaying biggest itemNo for category and subCategory with sorting data by itemNo descending and then calling {First(amount)} and {First(totalAmount)} but now i am having problems for sums if i have 2 or more subCategories i cannot manage to sum amount for first item on each subCategory and same for category

    I tried these two options:

    [code]{Sum(IIF(subCategory = First(subCategory, “subCategory”), IIF(itemNo = Max(itemNo, “subCategory”), totalAmount, 0), 0))}

    {Sum(IIF(itemNo = Max(itemNo, “subCategory”), totalAmount, 0), “subCategory”)}[/code]

    https://developer.mescius.com/activereportsjs/demos/Reports/LogisticsCost2/purejs

  • Posted 3 December 2023, 9:10 pm EST

    Hi Arian,

    We are not sure we fully understand your requirements, from what we understand you are grouping data into categories and subcategories, in both you want to show the amount and totalAmount of the biggest ‘itemNo’ then in the subCategory you want to show the total sum of totalAmount for each subCategory but only for the biggest itemNo in each subCategory, however, each subCategory will have only one biggest itemNo and the total will appear after the end of each subCategory so it is not clear how you want to show the sum of the same (as there will be only one largest value in each subCategory).

    Could you please share a sample database along with a mock report output (for example a sample Excel document) that shows the expected output for your sample data so we can assist you further regarding the same?

    Please Note: It is suggested to create a new case for every new issue you have as it helps us avoid any confusion and helps others looking for their related queries on our forums.

    Thanks,

    Anand

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels