Friday, December 4, 2015

When making expandable rows in a DevExpress grid you may need to decorate the type you bind in a list with a fake ID.

If you don't make the KeyFieldName setting here I think you'll find that trouble may arise. In the background, it feels like an ID is being picked for you somehow if you don't set one yourself and this allows for circumstances in which two rows may have the same ID and two rows may expand open when one is clicked. In the absence of having an applicable ID, why don't you just make one? Put a getsetter on your POCO. Before handing back a list of Foo just set the fake IDs like so:

var counter = 0;
for (int index = 0; index < foos.Count; index++)
{
   var foo = foos[index];
   counter++;
   foo.PseudoId = counter;
}
return foos;

 
 

You cannot just make a setterless getsetter that just hands back a random Guid. I tried that.

No comments:

Post a Comment