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

How to make a merge cell in dynamic table?

2 Answers 162 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Hojun
Top achievements
Rank 1
Hojun asked on 14 Nov 2016, 09:23 AM

Hello.

I need your help please. first my development conditions are limited. i can't use the Design tap just use program code. bcs does not work a sqlDataSource tool in Telerik. to connect a DB server only use our cust command. retrun type is a DataTable when use cust command.

so i found tip and succeeded by reference this code.

------------------------------------------------------------------------------------------------------------

private void table1_NeedDataSource(object sender, EventArgs e)
{
  //HttpContext context = HttpContext.Current;    // If you need the table from Session
  //DataTable dt = (DataTable)context.Session["data"];

  DataTable dt2 = new DataTable();
  dt2.Clear();
  dt2.TableName = "name table 2";
  dt2.Columns.Add("column1");
  dt2.Columns.Add("column2");
  DataRow _rowAdd = dt2.NewRow();
  _rowAdd["column1"] = "11";
  _rowAdd["column2"] = "55";
  dt2.Rows.Add(_rowAdd);

  _rowAdd = dt2.NewRow();
  _rowAdd["column1"] = "22";
  _rowAdd["column2"] = "33";
  dt2.Rows.Add(_rowAdd);

  _rowAdd = dt2.NewRow();
  _rowAdd["column1"] = "aa";
  _rowAdd["column2"] = "bb";
  dt2.Rows.Add(_rowAdd);

  //if you need to rename the columns:
  //for (int k = 0; k < dt.Columns.Count; k++)
  //{
  //    dt.Columns[k].ColumnName = dt.Columns[k].ColumnName.ToLower().Replace("|", "").Replace(" ", "").Replace("\", "");
  //}

  table1.DataSource = dt2;

  Telerik.Reporting.HtmlTextBox textboxGroup;
  Telerik.Reporting.HtmlTextBox textBoxTable;
  table1.ColumnGroups.Clear();
  table1.Body.Columns.Clear();
  table1.Body.Rows.Clear();
  int ColCount = dt2.Columns.Count;
  for (int i = 0; i <= ColCount -1; i++)
  {

    Telerik.Reporting.TableGroup tableGroupColumn = new Telerik.Reporting.TableGroup();
    table1.ColumnGroups.Add(tableGroupColumn);
    tableGroupColumn.Name = i.ToString();  //very important this "Name" because of a Telerik bug is needed
    textboxGroup = new Telerik.Reporting.HtmlTextBox();
    textboxGroup.Style.BorderColor.Default = Color.Black;
    textboxGroup.Style.BorderStyle.Default = BorderType.Solid;
    textboxGroup.Value = dt2.Columns[i].ColumnName;
    textboxGroup.Size = new SizeU(Unit.Inch(1.1), Unit.Inch(0.3));
    tableGroupColumn.ReportItem = textboxGroup;
    textBoxTable = new Telerik.Reporting.HtmlTextBox();
    textBoxTable.Value = "=Fields." + dt2.Columns[i].ColumnName;
    textBoxTable.Size = new SizeU(Unit.Inch(1.1), Unit.Inch(0.3));
    table1.Body.SetCellContent(0, i, textBoxTable);
    table1.Items.AddRange(new ReportItemBase[] { textBoxTable, textboxGroup });

  }
}

------------------------------------------------------------------------------------------------------------

When i have succeeded up to screen is 'now.png' file and what I want here is a SEQNO cell merge. like 'want.png'

And return table is dynamic. often change a rows of a SEQNO and SUBNO column.

i found cell merge tip in this fourm. but other tips used a Design tap or not dynamic table.

I could not find to code it. so i need help.

Thank you.

2 Answers, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 14 Nov 2016, 03:20 PM
Hello Hojun,

Based on your screenshot - want.png, this is not a merged cell but a grouping cell.

Before creating the item programmatically, opt for Visual Studio Report Designer. Use test data and the Table Wizard to create the standard layout. Then selected the Table item and open the Group Explorer to add a parent row group to the detail row group of the Table item. For more details check Grouping Data.

At the end you will have auto-generated code in the VS report's designer.cs|vb file that can be re-used and adjusted at run-time. The approach should be used on creating items at run-time in order to verify all required settings will be set.
At the end you can serialize the modified Telerik.Reporting.Report instance to check the result layout with the Standalone Report Designer.

Regards,
Stef
Telerik by Progress
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
0
Hojun
Top achievements
Rank 1
answered on 15 Nov 2016, 04:17 AM

Great! i solved this problem.

Thank you.

Tags
General Discussions
Asked by
Hojun
Top achievements
Rank 1
Answers by
Stef
Telerik team
Hojun
Top achievements
Rank 1
Share this question
or