How I can bind devexpress report table to list of strings?

1.7k views Asked by At

I try to create report with a table and bind it to a list of string (about 10000 items).

I tried to create row in runtime, but it is very slow:

String[] ids = GetIds();
DetailTable.BeginInit();
foreach (String id in ids)
{
     XRTableRow newRow = new XRTableRow();
     XRTableCell newCell = new XRTableCell();
     newCell.Text = id;
     newRow.Cells.Add(newCell);
     DetailTable.Rows.Add(newRow);
}
DetailTable.EndInit(); 

Also I tried to bind cell, but in report I can see only first row:

var ids = GetIds().Select(id => new {Id = id});
this.DataSource = ids;
IdCell.DataBindings.Add(new XRBinding("Text", DataSource, "Id"));

How I can fill my table?

1

There are 1 answers

0
XzajoX On

I'd like to see your design view of the report too. I am doing this as follows (on the Design view):

  1. Put one xrTable to a DetailReport - that would be the table header, just fixed texts, maybe some formatting (background, font, etc...), I assume your table will have only one column.
  2. insert another DetailReport (inside the first one by right-clicking on its name and selecting Insert Detail Report)
  3. inside this second one put another xrTable of the same size, and number of columns (there you will put the data)
  4. click on the smart tag of this second DetailReport, add the datasource (a model, where your list is) and point the DataMember to your List item.
  5. I donĀ“t know if it will map itself to the string values of your list. Probably not, so I'd change your List[[string]] to e.g. a List[[MyOneColumnClass]] where the MyOneColumnClass is just a class with only one public string Value {get; set;} Then you will point the DataMember to the field [Value] (just type the word in brackets into the xrTableCell text.