This is a migrated thread and some comments may be shown as answers.

Grouping Data in A table

3 Answers 90 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Aubrey Ivan
Top achievements
Rank 1
Aubrey Ivan asked on 09 Dec 2019, 09:59 AM
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




3 Answers, 1 is accepted

Sort by
0
Aubrey Ivan
Top achievements
Rank 1
answered on 09 Dec 2019, 09:59 AM
I forgot to change the 8500 Debit and Credit to 2500
0
Aubrey Ivan
Top achievements
Rank 1
answered on 09 Dec 2019, 10:09 AM
Whenever I do this the data is incomplete, what am I doing wrong?
0
Todor
Telerik team
answered on 12 Dec 2019, 08:53 AM

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
Tags
General Discussions
Asked by
Aubrey Ivan
Top achievements
Rank 1
Answers by
Aubrey Ivan
Top achievements
Rank 1
Todor
Telerik team
Share this question
or