Data Source Business Objects

7 posts, 0 answers
  1. Marco Teodoro
    Marco Teodoro avatar
    53 posts
    Member since:
    Apr 2010

    Posted 11 May 2010 Link to this post

    Hello,
    I have a function that will return my dataSource to telerik report. 
    But i have some doughs? 

    See the above sample 
    public class dataSourceObj 
        public string Name {get; set;} 
        public ComplexType ComplexDto {get; set;} 
    }  
     
    public class ComplexType  
        public string ComplexTypeName {get; set;} 
        public int id  {get; set;} 
        public List< subType> subTypeList {get; set;} 
     
    public class subType 
        public string subTypeName {get; set;} 
        public int id  {get; set;} 
        public int ComplexTypeid  {get; set;} 
     

    So if i create a datasource to my report and set some function to return the dataSourceObj class i will see the properties Name, complexType, and inside this one i will see -> ComplexTypeName and id but not subTypeList.

    Why this is happening?

    Best Regards
    Marco Teodoro
  2. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 14 May 2010 Link to this post

    Hi Marco Teodoro,

    Because it is a collection property within your business object and we do not drill down into the hierarchy. If your purpose is to bind a data item (i.e. report, table, chart) to this collection, you can use the Bindings property. This way you can bind declaratively the DataSource property of a data item to a given collection property from your business object and the data item will display all the collection items. To illustrate this approach better I have attached a small sample report to my post. If you need more information regarding this you can visit the following help topic from our online documentation which discusses property bindings via expressions more in-depth.

    Regards,
    Steve
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. DevCraft banner
  4. Marco Teodoro
    Marco Teodoro avatar
    53 posts
    Member since:
    Apr 2010

    Posted 14 May 2010 Link to this post

    Hello Steve,

    i have made some modification on the sample you have attached to accomplish my needs but unfortunately i can't make it work.

    this is my dataSource:

     [DataObject] 
        public class ReportData 
        { 
     
            public string Name { get; set; } 
            public List<SampleModel> dataSourceList { get; set; } 
            [DataObjectMethod(DataObjectMethodType.Select)] 
            public ReportData GetModel() 
            { 
                this.Name="dataSourceName"
                this.dataSourceList = new List<SampleModel> 
                { 
                    new SampleModel 
                    { 
                        Name = "Sample Model 1"
                        Value=1
                        sampleItem = new SampleItem 
                        { 
                            Name = "Sample Item 1"
                            Items = new List<SampleSubItem> 
                            { 
                                new SampleSubItem { Name = "SubItem 1"Value = 1 }, 
                                new SampleSubItem { Name = "SubItem 2"Value = 2 }, 
                                new SampleSubItem { Name = "SubItem 3"Value = 3 }, 
                                new SampleSubItem { Name = "SubItem 4"Value = 4 }, 
                                new SampleSubItem { Name = "SubItem 5"Value = 5 }, 
                                new SampleSubItem { Name = "SubItem 6"Value = 6 }, 
                                new SampleSubItem { Name = "SubItem 7"Value = 7 }, 
                                new SampleSubItem { Name = "SubItem 8"Value = 8 }, 
                                new SampleSubItem { Name = "SubItem 9"Value = 9 } 
                            } 
                        } 
                    }, 
                    new SampleModel 
                    { 
                        Name = "Sample Model 2"
                        Value=2
                        sampleItem = new SampleItem 
                        { 
                            Name = "Sample Item 2"
                            Items = new List<SampleSubItem> 
                            { 
                                new SampleSubItem { Name = "SubItem 1"Value = 1 }, 
                                new SampleSubItem { Name = "SubItem 2"Value = 2 }, 
                                new SampleSubItem { Name = "SubItem 3"Value = 3 }, 
                                new SampleSubItem { Name = "SubItem 4"Value = 4 }, 
                                new SampleSubItem { Name = "SubItem 5"Value = 5 }, 
                                new SampleSubItem { Name = "SubItem 6"Value = 6 }, 
                                new SampleSubItem { Name = "SubItem 7"Value = 7 }, 
                                new SampleSubItem { Name = "SubItem 8"Value = 8 }, 
                                new SampleSubItem { Name = "SubItem 9"Value = 9 } 
                            } 
                        } 
                    } 
                    , 
                    new SampleModel 
                    { 
                        Name = "Sample Model 3"
                        Value=3
                        sampleItem = new SampleItem 
                        { 
                            Name = "Sample Item 3"
                            Items = new List<SampleSubItem> 
                            { 
                                new SampleSubItem { Name = "SubItem 1"Value = 1 }, 
                                new SampleSubItem { Name = "SubItem 2"Value = 2 }, 
                                new SampleSubItem { Name = "SubItem 3"Value = 3 }, 
                                new SampleSubItem { Name = "SubItem 4"Value = 4 }, 
                                new SampleSubItem { Name = "SubItem 5"Value = 5 }, 
                                new SampleSubItem { Name = "SubItem 6"Value = 6 }, 
                                new SampleSubItem { Name = "SubItem 7"Value = 7 }, 
                                new SampleSubItem { Name = "SubItem 8"Value = 8 }, 
                                new SampleSubItem { Name = "SubItem 9"Value = 9 } 
                            } 
                        } 
                    } 
                }; 
                return this; 
            } 
        } 
     
        public class SampleModel 
        { 
            public string Name { get; set; } 
            public int Value { get; set; } 
            public SampleItem sampleItem { get; set; } 
        } 
     
        public class SampleItem 
        { 
            public string Name { get; set; } 
            public List<SampleSubItem> Items { get; set; } 
        } 
     
        public class SampleSubItem 
        { 
            public string Name { get; set; } 
            public int Value { get; set; } 
        } 

    so far i was able to see and render the list of sample models using one table and binding it using the =Fields.DataSourceList

    and then on table i'm using =Fields.Name and =Fields.Value.

    so far so good.

    my question now is: how can i bind sample item class?

    can i send you my modified sample?
    hope you can help me,
    best regards
    Marco Teodoro
  5. Hrisi
    Admin
    Hrisi avatar
    221 posts

    Posted 20 May 2010 Link to this post

    Hello Marco,

    You can bind it in similar way i.e you should nest another Data Item (Table, SubReport, Chart) in the table
    cell.

    ReportData                                                             -> bound to report through DataSource
        Name
        dataSourceList(List<SampleModel>)           -> bound to table through Bindings expression
            Name
            Value
            sampleItem(SampleItem)
                Name
                Items(List<SampleSubItem>)                 -> bound to nestedTable through Bindings expression
                    Name
                    Value

    You can see the pattern - collections are bound to Data Items, primitive types -  to the rest of report items (TextBox, PictureBox ...). Sample project is attached for your convenience.

    Sincerely yours,
    Hrisi
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  6. kero
    kero avatar
    1 posts
    Member since:
    Dec 2010

    Posted 28 Dec 2010 Link to this post

    new SampleModel
                    {
                        Name = "Sample Model 1",
                        Value=1,
                        sampleItem = new SampleItem
                        {
                            Name = "Sample Item 1",
                            Items = new List<SampleSubItem>
                            {
                                new SampleSubItem { Name = "SubItem 1", Value = 1 },
                                new SampleSubItem { Name = "SubItem 1", Value = 1 },
                                new SampleSubItem { Name = "SubItem 1", Value = 1 },
                                new SampleSubItem { Name = "SubItem 1", Value = 1 },
                                new SampleSubItem { Name = "SubItem 1", Value = 1 },
                                new SampleSubItem { Name = "SubItem 1", Value = 1 },
                                new SampleSubItem { Name = "SubItem 1", Value = 1 },
                                new SampleSubItem { Name = "SubItem 1", Value = 1 },
                                new SampleSubItem { Name = "SubItem 1", Value = 1 }
                            }
                        }
                    },
                    new SampleModel
                    {
                        Name = "Sample Model 2",
                        Value=2,
                        sampleItem = new SampleItem
                        {
                            Name = "Sample Item 2",
                            Items = new List<SampleSubItem>
                            {
                                new SampleSubItem { Name = "SubItem 2", Value = 2 },
                                new SampleSubItem { Name = "SubItem 2", Value = 2 },
                                new SampleSubItem { Name = "SubItem 2", Value = 2 },
                                new SampleSubItem { Name = "SubItem 2", Value = 2 },
                                new SampleSubItem { Name = "SubItem 2", Value = 2 },
                                new SampleSubItem { Name = "SubItem 2", Value = 2 },
                                new SampleSubItem { Name = "SubItem 2", Value = 2 },
                                new SampleSubItem { Name = "SubItem 2", Value = 2 },
                                new SampleSubItem { Name = "SubItem 2", Value = 2 }
                            }
                        }
                    }
                    ,
                    new SampleModel
                    {
                        Name = "Sample Model 3",
                        Value=3,
                        sampleItem = new SampleItem
                        {
                            Name = "Sample Item 3",
                            Items = new List<SampleSubItem>
                            {
                                new SampleSubItem { Name = "SubItem 3", Value = 3 },
                                new SampleSubItem { Name = "SubItem 3", Value = 3 },
                                new SampleSubItem { Name = "SubItem 3", Value = 3 },
                                new SampleSubItem { Name = "SubItem 3", Value = 3 },
                                new SampleSubItem { Name = "SubItem 3", Value = 3 },
                                new SampleSubItem { Name = "SubItem 3", Value = 3 },
                                new SampleSubItem { Name = "SubItem 3", Value = 3 },
                                new SampleSubItem { Name = "SubItem 3", Value = 3 },
                                new SampleSubItem { Name = "SubItem 3", Value = 3 }
                            }
                        }
                    }

    Please, modify your sample as follow.
    There are bug, in all rows will be nested list from first element
    Is there any way to fix it?
  7. Support ATT
    Support ATT avatar
    66 posts
    Member since:
    Nov 2004

    Posted 25 Jul 2014 in reply to Hrisi Link to this post


    Hello Telerik

    With this Solution it will show all Items (SamplyModel) on one Page. So if you have over 5000 Objects it will be very slow to scroll. How you implement the PageBreak that it create a new Page if it reaches at the end of an A4 Pages ...

    Thank you for you help.

    regards
    David

  8. Stef
    Admin
    Stef avatar
    3036 posts

    Posted 29 Jul 2014 Link to this post

    Hi,

    For anyone concerned, below is a quote from my reply in his support ticket:

    "Page breaks are only supported by report sections. The Table item is rendered continuously on a single page in Interactive preview, which may cause you issues in certain browsers when there are more than the allowed for the browser elements. For more details and solution, please check the Design Considerations for HTML Rendering article.

    Other approach is to reorganize the report by data-binding the report, setting up report group, adding the Table to the group header section (or other section), set the group header page break to PageBreak.After and data-binding the Table with a Binding expression.
    ..."

    All the best,
    Stef
    the Telerik team
     
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
     
Back to Top
DevCraft banner