It doesn't seem possible to directly sort the rows at this time. You could copy the cells data, sort it, and assign it back to the rows instead. For example, this sorts the cells under a single header:
private void diagram_CellClicked(object sender, CellEventArgs e)
{
TableNode table = e.Table;
TableNode.Row row = table.Rows[e.Row];
if (row.Header && e.Column == 1)
{
List<string> sectionData = GetSectionData(table, e.Row);
sectionData.Sort();
SetSectionData(table, e.Row, sectionData);
}
}
List<string> GetSectionData(TableNode table, int headerRow)
{
List<string> data = new List<string>();
for (int i = headerRow + 1; i < table.RowCount; ++i)
{
if (table.Rows[i].Header)
break;
data.Add(table[0, i].Text);
}
return data;
}
TableNode TestSortTable()
{
TableNode table = diagram.Factory.CreateTableNode(
0, 0, 40, 150,// bounds
2, 8);// columns x rows
table[0, 0].Text = "header 1";
table[0, 1].Text = "z";
table[0, 2].Text = "y";
table[0, 3].Text = "x";
table[0, 4].Text = "header 2";
table[0, 5].Text = "b";
table[0, 6].Text = "c";
table[0, 7].Text = "a";
table.Rows[0].Header = true;
table[1, 0].Image = sortIcon;
table.Rows[4].Header = true;
table[1, 4].Image = sortIcon;
table.OffsetHeaderRows = true;
return table;
}
I hope that helps,
Stoyan