Load data only the fields that already drop in the report

Posted by: xuan.nguyen on 19 June 2024, 3:36 am EST

    • Post Options:
    • Link

    Posted 19 June 2024, 3:36 am EST - Updated 19 June 2024, 9:29 pm EST

    Hi all,

    My DataSets has a lot of fields. And the API will load them all.



    I want to load only the fields that already drop in the report.

    How can i get that fields in report page and modify the uri to satisfy the above ?

    I’m using ActiveReportJS 4.2.

    Thanks,

  • Posted 21 June 2024, 7:35 am EST

    Hi Xuan,

    For this, I would suggest you to edit the report JSON before loading the report into the designer.

    All fields used in any expression is always in either of the two formats:

    Fields!<fieldname>.Value
    

    OR

    Fields.Item("<field name>").Value
    

    You may field all the field names from report.DataSets[].Fields[].Name into the report by searching for field expressions.

    If there is no expression found you may simply remove the field from report.DataSets[].Fields[] array.

    Once you have removed all the fields which are not used, you may then call the designer.setReport method and set the report definition using the modified report JSON.

    Please refer to the attached sample.

    Designer-LimitedFields.zip

  • Posted 24 June 2024, 12:46 am EST

    Hello Akshay,

    Thank you very much! It worked for me.

    But I have a small problem with that. When I have two datasets with the same field names. I’m just dropping one field of a dataset into the report. The API will then load the data for that field of the two datasets.

    Do you have any ideas to solve it?

    Thank,

  • Posted 24 June 2024, 2:55 am EST

    Hi Xuan,

    Thanks for pointing this out to us. This would be a limitation of using this approach as fields can be used in multiple ways in a report with DataSets Sometimes mentioned in expression or in any parent control.

    Because of this, I would suggest you to either have unique name for fields or just remove the unused duplicate fields manually.

    Unfortunately, There seems to be no other viable way to do this without have some edge cases like the one you mentioned.

  • Posted 24 June 2024, 3:04 am EST

    Hi Akshay,

    Thanks for your response. You saved my days.

Need extra support?

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

Learn More

Forum Channels