This is a migrated thread and some comments may be shown as answers.

[Solved] Inject secondary rows after with grouping on

2 Answers 45 Views
Grid for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Yuri
Top achievements
Rank 1
Yuri asked on 17 Jul 2013, 09:15 PM
I am trying to achieve the following:
- Have a RadDataGrid with grouping by one of the 2 externally selected properties, or without grouping at all.
- At the root level the grid would hold items of a certain business type.
- I want to be able to inject "child" items (of the same business type) right below their "parent" items. For these child items I want their position to *not* be affected by the dynamically changing grouping criteria, but to have them always shown under their parent.

What is the best approach to achieve this?

As far as I can tell, even if I inject the child items *after* the grouping has been applied their location in the grid will still be influenced by the grouping. Is there any way to make them "immune" to grouping?

I thought about maybe manipulating the GetDataView().Items - but they are read-only.

I also don't want to use multilevel grouping, because the "parent" items need to be presented in the UI as data, not as group headers.
Please advise.

2 Answers, 1 is accepted

Sort by
0
Yuri
Top achievements
Rank 1
answered on 18 Jul 2013, 04:55 PM
I was able to achieve the desired result by applying the following hack:
- Added an integer property OrdinalNumber to the Order class.
- Added to the RadDataGrid a new DelegateSortDescriptor that uses that OrdinalNumber for sorting.
- After the sorting required by the business logic had been applied, assigned all the Order instances (both parent and child) with auto-incremented OrdinalNumber.
- Modified the grouping KeyLookups to use the parent Order's property in case the instance is a child Order. This way it will appear under the same group as its parent, even if their values of the grouping criterion are different.

This works, but there must be a better way...
0
Ivaylo Gergov
Telerik team
answered on 22 Jul 2013, 12:17 PM
Hello Yuri,

Unfortunately, this is a very specific scenario that is not supported by the RadDataGrid control. As I cannot suggest a possible workaround you can use the one that you have already applied(if it works for you).

Let me know should you have further questions.

Regards,
Ivaylo Gergov
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Grid for XAML
Asked by
Yuri
Top achievements
Rank 1
Answers by
Yuri
Top achievements
Rank 1
Ivaylo Gergov
Telerik team
Share this question
or