Grouping Data in A table

4 posts, 0 answers
  1. Aubrey Ivan
    Aubrey Ivan avatar
    25 posts
    Member since:
    Oct 2019

    Posted 09 Dec 2019 Link to this post

    I am using telerik reporting and custom data source, I have a data like this


    var purchaseJournal = new PurchaseJournal();
    var dateToday = DateTimeOffset.Now;

    var lineItemAccountStatement1 =
    new LineItemAccountStatement
    {
        GroupNo = 1,
        INV_NO = "INV1_APV1",
        ReportDate = dateToday,
        Vendor = "Vendor A",
        EnteredDebit = 700,
        LineItemID = Guid.NewGuid(),
    };
     
    var lineItemAccountStatement2 = new LineItemAccountStatement
    {
        GroupNo = 1,
        INV_NO = "INV1_APV1",
        ReportDate = dateToday,
        Vendor = "Vendor B",
        EnteredCredit = 700,
        LineItemID = Guid.NewGuid(),
    };
     
    var lineItemAccountStatement3 = new LineItemAccountStatement
    {
        GroupNo = 2,
        INV_NO = "INV2_APV2",
        ReportDate = dateToday,
        Vendor = "Vendor C",
        EnteredDebit = 8500,
        LineItemID = Guid.NewGuid(),
    };
     
    var lineItemAccountStatement4 = new LineItemAccountStatement
    {
        GroupNo = 2,
        INV_NO = "INV2_APV2",
        ReportDate = dateToday,
        Vendor = "Vendor D",
        EnteredCredit = 8500,
        LineItemID = Guid.NewGuid(),
    };
     
    purchaseJournal.LineItemAccountStatements = new List<LineItemAccountStatement>
    {
        lineItemAccountStatement1,
        lineItemAccountStatement2,
        lineItemAccountStatement3,
        lineItemAccountStatement4
    };



    I want to output a table like this




  2. Aubrey Ivan
    Aubrey Ivan avatar
    25 posts
    Member since:
    Oct 2019

    Posted 09 Dec 2019 in reply to Aubrey Ivan Link to this post

    I forgot to change the 8500 Debit and Credit to 2500
  3. Aubrey Ivan
    Aubrey Ivan avatar
    25 posts
    Member since:
    Oct 2019

    Posted 09 Dec 2019 in reply to Aubrey Ivan Link to this post

    Whenever I do this the data is incomplete, what am I doing wrong?
  4. Todor
    Admin
    Todor avatar
    412 posts

    Posted 12 Dec 2019 Link to this post

    Hi Aubrey Ivan,

    I have attached a sample report using the provided code for a data source and a Table to display the data as seen on the screenshot. Here are the major steps:

    • use an instance of PurchaseJournal as Report DataSource - in the sample, Data.GetData() method returns such object
    • use Bindings to set the Table DataSource to its parent's (i.e. Report's) DataSource field LineItemAccountStatements
    • add a new parent group to the Table through the Group Explorer - check the 'Add Footer' checkbox as there we will type the Sum (or another aggregate) for the group there. Optionally you may add also a Group Header from the other checkbox of the Table Group editor
    • type the fields you want to be displayed in the table manually. This is necessary as the values are set with Bindings to a collection and can be resolved only runtime. For that reason, in design time the names of the fields are not accessible
    • add the Total values in the Group Footer

    I have attached a sample demonstrating the approach.

    Regards,
    Todor
    Progress Telerik

    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 Feedback Portal and vote to affect the priority of the items
Back to Top