Hi,
I would like to have a header that include some columns and I want it to react properly when columns move. I tried many different options and I never succeed to make it work correctly. The best I found is to add a column with no data in the row zero and add the "children" columns on the row one.
Example:
Based on the example, I want to add the group "Persons" but I just want it to be an identifier that groups the columns Firstname and Lastname. If I move Persons (in a larger table), the columns Firstname et Lastname would move with it. Inside Persons, I want to still be able to change the column Firstname and Latname positions.
Do you know if the XamDataGrid support this kind of grouping and if yes, how can I use it.
Hello,
Currently, the XamDataGrid does not support this out of the box. What you could do is handle the FieldPositionChanging event( which will fire before the field changes position) and save its position. Then you can handle the FieldPositionChanged (which fires after the position has changed) and move the rest of the fields which are dependant of the currently moving one. You can do that by setting a new ActualPosition for them, Something like:
if (e.Field.Name == "Persons")
{
e.Field.Owner.Fields["PersonFirstName"].ActualPosition = new FieldPosition(fp.Column, fp.Row + 1, 1, 1);
e.Field.Owner.Fields["PersonLastName"].ActualPosition = new FieldPosition(fp.Column + 1, fp.Row + 1, 1, 1);
}
where fp is the Persons Field's ActualPosition.
I am attaching a sample implementation of this approach.
Thanks, I'll use that approach.
Regards,
I have expanded this sample a little bit. Now it is more generic and should be able to handle group of fields with different number of fields, removing the hard coded values of Field names.
It works most of the time correctly, but there are still one or two issues that I have to fix, but you can take a look as well.
Hi Alex,
I need to do something pretty much the same as this (which looks like the column grouping you have in the silverlight grid) but in this example the data row takes up two rows as well as the heading row. I dont want the (blank) datarows to be visible as they are in this sample. What can I do to stop this please?
Regards,Doug Rees