Hey there,
in my grid, i got a lot of nearly equal rows. For a better clarity, i only want to see the first line and all others should collaps underneth it. To achieve this, i parse each following line into the collection in the first line. This is my Method for this (C#):
private DataTable collapseDoubleRows(DataTable DataSource)
{
DataSource.Columns.Add("CollapsedRows", typeof(List<DataRow>));
DataTable retTable = DataSource.Clone();
List<string> Texts = new List<string>();
foreach (DataRow dr in DataSource.Rows)
if (Texts.IndexOf(dr["Text"].ToString()) == -1)
Texts.Add(dr["Text"].ToString());
foreach(string s in Texts)
DataRow[] rows = DataSource.Select("Text = '" + s + "'");
DataRow newRow = retTable.NewRow();
newRow.ItemArray = rows[0].ItemArray;
if (rows.Length > 1)
newRow["CollapsedRows"] = rows.Skip(1).Take(rows.Length - 1).ToList();
retTable.Rows.Add(newRow);
}
return retTable;
The method works fine for me. My problem is, when i expand the row, the opening rows got no cloumn or values.
I hope, my description was clear enough :)
Hello Manfred,
It will be really hard to make this to works, sines you should use PropertyDescriptor in order to “say” to ultraGrid that “CollapsedRows” is actually second band. Instead my advice is to generate appropriate dataset, so your method should looks like:
private DataSet collapseDoubleRows(DataTable DataSource)
DataSet retSet = new DataSet();
DataTable parent = DataSource.Clone();
DataTable child = DataSource.Clone();
retSet.Tables.Add(parent);
retSet.Tables.Add(child);
List Texts = new List();
foreach (string s in Texts)
DataRow newRow = parent.Rows.Add(rows[0].ItemArray);
for (int i = 1; i < rows.Length; i++)
child.Rows.Add(rows[i].ItemArray);
retSet.Relations.Add(parent.Columns["Text"], child.Columns["Text"]);
return retSet;
Please let me know if you have any further questions.