Subreports when inheriting from IC1ReportRecordset

Posted by: steronz on 3 August 2017, 3:12 am EST

  • Posted 3 August 2017, 3:12 am EST

    I'm converting some existing reports (loaded against datatables) to a new project where we're using an ORM.  I found instructions for nesting our ORM objects in a class that inherits from IC1ReportRecordset, so I've got something like this:


    public class ReportRecordSet : IC1ReportRecordset
            {
                private int _pos;
                private List<MyOrmObject> _data = new List<MyOrmObject>();

                public void Add(MyOrmObject item)
                {
                    _data.Add(item);
                }
                string[] IC1ReportRecordset.GetFieldNames()
                {
                    return new string[] { "ID", "SOME_VALUE" };
                }
                Type[] IC1ReportRecordset.GetFieldTypes()
                {
                    return new Type[] { typeof(long), typeof(string) };
                }
                object IC1ReportRecordset.GetFieldValue(int fieldIndex)
                {
                    switch (fieldIndex)
                    {
                        case 0:
                            return _data[_pos].Id;
                        case 1:
                            return _data[_pos].Value;
                    }
                    return null;
                }


    //etc...


    I then throw all my objects into the list contained in an instance of this class and everything shows up fine on my report, except my subreports aren't limiting to the relevant IDs.  So when I run the report with 2 principles, ID = 1 and ID = 2, where each principle has 2 items in a subreport, I get all 4 items on both pages.  I have the "ID = " & ID set as the text for the subreport, but it doesn't seem to work.  When I convert my ORM objects into a datatable, everything works fine, but I'd rather not go through all the overhead of translating all my report data into datatables when this solution otherwise seems to work fine.


    Is this a known limitation of the ICReportRecordset?  Am I missing some setting somewhere?  I've tried a bunch of different things but I just feel like I'm floundering now.  Thanks.


     

  • Replied 3 August 2017, 3:12 am EST

    In your case you also should implement method: ApplyFilter(string) of IC1ReportRecordset because relation between master and child reports set via this method, this method should be implemented at least for detail report.

  • Replied 3 August 2017, 3:12 am EST

    Thank you!  That's the part I was missing.  Got the filtering working great now, just need to figure out the sort.  Well, I implemented the sort example that I found and stepped through it, and it's correctly sorting the generic list, but then it still displays on the report unsorted.  I'm sure I'll get it though, I haven't spent a lot of time on it.


    Your post helped immensely though, I had basically given up on doing it this way.  Thanks again!

  • Replied 17 December 2018, 7:47 pm EST

    This maybe a bit old but I can find an example of applying ApplyFilter, can you guys help me out with a simple example? I would really appreciate it, thank you so much!
  • Replied 27 February 2019, 5:56 pm EST

    Discussion of topic Subreports when inheriting from IC1ReportRecordset in ComponentOne Archives forum. u can visit our website u are looking for a good jobs. https://careerjobs360.in/
Need extra support?

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

Learn More

Forum Channels