Filter a column with custom type - "No coercion operator is defined between types […]"

3 posts, 0 answers
  1. Filip
    Filip avatar
    2 posts
    Member since:
    Jun 2014

    Posted 04 Jul 2014 Link to this post

    Hello!

    I'm trying to enable filtering on a column which is bound to a property of a object whose structure is something like this:

    Portfolios:
       - PortfolioInformationExtended:
          - String
       - PortfolioInformationExtended:
          - String
       - PortfolioInformationExtended:
          - String

    PortfolioInformationExtended is a sub-class of PortfolioInformation.

    I have tried to be diligent in my reading of the documentation and have implemented IComparable<PortfolioInfoExtended>, IEquatable<PortfolioInfoExtended>, IComparable<String>, IEquatable<String> in the PortfolioInfoExtended-class as per instructions here on the forum and in the documentation. 

    I have successfully gotten the column to group (when I drag the header) but when I try to filter it I get the error message:
    "No coercion operator is defined between types 'System.Collections.ObjectModel.ObservableCollection`1[MarketValueWeb.RateServiceReference.PortfolioInfo]' and MIQ.SilverlightExstenstion.Nordkap.PortfolioInfoExtended'.

    The DataType property of this column is set to PortfolioInformation, and since the grouping works the operators seem to be working.

    I am a bit confused by this and is wondering if I have missed some obvious step, or if everything seem to be in order. Any suggestions on how to proceed?

    Thanks in advance!








  2. Filip
    Filip avatar
    2 posts
    Member since:
    Jun 2014

    Posted 07 Jul 2014 in reply to Filip Link to this post

    Ok, I have investigated this further and realised that the problem lies in the fact that the itemSource the column is bound to is a collection of my objects and that the search function returns a single object. 

    If I implement a implicit operator between my class and my list, it seems to work. However, I don't get any "suggestions" (where you normally can click boxes). I have implemented ToString() on my object, but that does not seem to help.
  3. DevCraft banner
  4. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 07 Jul 2014 Link to this post

    Hello,

    This error says that you try to use a value that is of diffident type than the column's values. If the actual type of the property is a ObservableCollection`1[MarketValueWeb.RateServiceReference.PortfolioInfo]' , then it cannot be treated as a PortfolioInfoExtended оr а string, because comparisons have to be made and those two types don't compare to each other out-of-the-box.  

    You should ensure the DataType of the bound data is the same as the DataType of the Value you set. 

    Regards,
    Didie
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top