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

GroupMemberPath with IValueConverted columns

2 Answers 199 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rodro
Top achievements
Rank 2
Rodro asked on 27 Sep 2011, 02:20 AM
Hi,

I have this situation where my business object exposes a DateTime property
and I'm binding a GridViewDataColumn to that property using a custom IValueConverter
which "simplify" the date. It converts the datetime to a string, something like "today, 10:15" or
"September 1st, 9:45" (without the current year). The point is that the target value is now a string.

Then I set up a GroupMemberPath to point at "MyProperty.Date" in order to group by day.

I just realized that group headers get populated by accessing that special path and pushing the value
through whatever IValueConverter is specified in the DataMemberBinding.

The only problem is that I cannot set a different ConverterParameter, so the time portion
(which is included in the "simplified" output) gets printed as well (00:00 in all groups).

The point is: wouldn't it be better to have a "GroupMemberBinding" instead of "GroupMemberPath"?
So that if a different conversion is needed for the grouped data to make sense we can specifiy
a different converter and/or converterParameter?

Am I splitting a hair?  :-)

Thanks.

-Rodrigo-

2 Answers, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 29 Sep 2011, 03:55 PM
Hello Rodro,

Internally RadGridView uses LINQ to group data, therefore RadGridView uses a simple "property path" to create a proper expression. In order to customize group header you don't need binding you could use any of the properties listed below:

1. RadGridView.GroupHeaderTemplate property.
2. GridViewColumn.GroupHeaderFormatString property.

Let me know if this doesn't help.

Greetings,
Nedyalko Nikolov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Rodro
Top achievements
Rank 2
answered on 30 Sep 2011, 03:41 AM
Hi Nedyalko,

I know that I can use either the GroupHeaderFormatString or the GroupHeaderTemplate,
but at that point my original DateTime has already been converted into a string by the converter
specified in DataMemberBinding.

My problem is that I would like to convert just the values that are displayed in the regular column
and use the real values from the source for grouping operations (as I would expect since I'm specifying a property path).

It looks like the grouping engine pulls the data out that property path, then uses the same converter
auto-magically (which might be good in some situations, but not all of them).

Of course I could use format strings for both datamember binding and groupheader, but there is no
smart date formatting options in the .net framework, so I guess the only option would be to use
a viewModel to wrap the original business object, just for this purpose.

-Rodrigo-

Tags
GridView
Asked by
Rodro
Top achievements
Rank 2
Answers by
Nedyalko Nikolov
Telerik team
Rodro
Top achievements
Rank 2
Share this question
or