Posted 17 August 2022, 12:31 pm EST - Updated 3 October 2022, 10:15 pm EST
Hi.
I have grid with row details, I need proper way to access parent row data object, so I could make proper query based on it’s fields.
Previously, I’ve used setup method:
public override void Setup(C1FlexGrid parentGrid, int rowIndex)
{
base.Setup(parentGrid, rowIndex);
var bs = parentGrid.DataSource as BindingSource;
var obj = bs.Current as SomeObj;
//query based on obj.Id
//setup child grid datasource
C1FlexGrid.OwnerDrawCell += C1FlexGridOnOwnerDrawCell;
}
But it seems to be wrong (buggy) becuase I relied on a fact that when I expand cell (click on cross, see img) then datasource raw will be selected accrodingly, but seems not to be the case. So, suppose that initially I select first row and then try to expand other rows details, then according to code above I would query data based on selected first row id, which is clearly wrong (wrong id).
So, to make this approach work correctly I need first explicitly select raw and then expand cell (cross sign), I think this is very poor user experience .
I 've tried to use followng approach:
var ht = intervalGrid.HitTest();
if (ht.Type == HitTestTypeEnum.Cell || ht.Type == HitTestTypeEnum.RowHeader)
{
var mi = grid.Rows[ht.Row].DataSource as DataObj;
Debug.Assert(mi != null, nameof(mi) + " != null");
return new M DetailRowContainer(mi.Id);
}
return null;
More or less it works until one start scrolling where things start working simply randomly, I mean I saw cases where after scroll child grid had data of another parent row.
So, the question is what is a correct approach for a child row to get it’s parent row ?
grid.RowDetailProvider = (g, r) =>
{
//TODO code here to get correct parent row
return new DetailRowContainer();
};
Thanks in advance.