Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
560
The following key has been defined more than once
posted

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

Parents
No Data
Reply
  • 40030
    Suggested Answer
    Offline posted

    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 

     

Children