79077217

Date: 2024-10-11 07:44:54
Score: 0.5
Natty:
Report link

Based from the hint from @QiangFu I did a bit more research. It seems to me, that the DatGrid requeries the database on expanding and isn't able to identify the new and the old instance to be the same dataset. It seems to work if equals() and GetHash() are overriden to identify the datasets by it's id.

public override bool Equals(object? obj)
{
    var OtherObjekt = obj as Testmodel;

    if (OtherObjekt != null)
    {
        if ((Id != null) && (OtherObjekt.Id != null))
        {
            if (Id == OtherObjekt.Id)
            {
                return true; ;
            }
            else
            {
                return false;
            }
        }
    }
    return base.Equals(obj);
}

public override int GetHashCode()
{
    if (Id != 0)
    {
        return Id;
    }
    return base.GetHashCode();
}

Nevertheless it is still not clear to me, why this is only relevant in case the RowExpand event is subscribed. Maybe someone else is able to tell if this is just a bug in RadzenDataGrid or if there is a serious reason for this behavior.

Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • User mentioned (1): @QiangFu
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Stef