I'm facing strange self-referencing grid behaviour. Symptoms:
1) All rows (even without children) contains "+"
2) Expanding parent row cause freeze without any exception thrown.
Object:
Grid contains columns for Code and Name defined in designer.
Than I'm adding self reference:
And data populating:
Thank for any suggestion in advance.
1) All rows (even without children) contains "+"
2) Expanding parent row cause freeze without any exception thrown.
Object:
public
class
MyObject
{
public
long
Id {
get
;
set
;}
public
string
Name {
get
;
set
;}
public
string
Code {
get
;
set
;}
public
MyObject Parent {
get
;
set
;}
}
Grid contains columns for Code and Name defined in designer.
Than I'm adding self reference:
GridViewTextBoxColumn col1 =
new
GridViewTextBoxColumn(
"Id"
,
"Id"
);
GridViewTextBoxColumn col2 =
new
GridViewTextBoxColumn(
"ParentId"
,
"Parent.Id"
);
grid.MasterTemplate.Columns.Add(col1);
grid.MasterTemplate.Columns.Add(col2);
grid.Columns[
"Id"
].IsVisible =
false
;
grid.Columns[
"ParentId"
].IsVisible =
false
;
grid.Relations.AddSelfReference(grid.MasterTemplate,
"Id"
,
"ParentId"
);
And data populating:
private
void
Populate(IList<MyObject> dataToPopulate)
{
this
.grid.BeginUpdate();
var relationsBackup =
this
.grid.Relations.ToList();
this
.grid.Relations.Clear();
this
.grid.DataSource = dataToPopulate;
this
.grid.Relations.AddRange(relationsBackup);
this
.grid.EndUpdate();
this
.grid.MasterView.Refresh();
}
Thank for any suggestion in advance.