Hello,
Another question:
We have a dataset with a datetime column named "TheDate". In the grid we want to show this date in a column along with a week number column and a day of the week column. These columns can all be based on the "TheDate" column from our dataset, but with different converters. When we add these columns with the same key (they all use "TheDate"), we get the error: "The following key has been defined more than once: TheDate.".
I understand that I can add the data column multiple times in our dataset with different names with the same data, but that's not really an option. It would give much overhead as this happens on several places in our application.
It is a pretty common scenario that someone uses the same property on different columns with different converters. Is there a decent solution for this problem?
Arjen
Hi Arjen,
The problem you're running into is by design. When building the control, we wanted to have unique column types, and missed the use case that you're proposing, of having multiple columns with the same data type. We will be sure to take this additional use case into review for future releases of the control.
However, its not impossible to achieve your goal, it just requires a bit more code. You can use a TemplateColumn, which gives you free range in how your data should be displayed. The TemplateColumn doesn't require its key to be in the data source. So you can use any uniquekey. Then in the ItemTemplate just create a binding to "TheDate" property.
Hope this helps,
-SteveZ
Hi Steve,
Thanks for the reply.
But by using this method, I would lose sorting, filtering and grouping on the TemplateColumn I guess?
Thanks for the feedback.
This sounds very close to a new feature we are currently working on for the XamWebGrid. We'll be sure to take this feedback into account as the feature progresses.
Hi Stephen,
Sorry for the delayed reply. We could use sorting on both the regular column and on the weeknumber column. For the day of the week column this would be pretty worthless I guess. And now that I think of it, is filtering and grouping done on the original data (before the dara is converted) or on the data after it has been converted by the value converter? It would only make sense to enable filtering and grouping if it is done on the converted data.
So, in this case, would you want the ability to Sort, Filter, and GroupBy on all of these columns, that are bound to the same data?
Or would you only allowing these features to be used on one of these columns?