Named FilterDescriptor not accessible?

4 posts, 1 answers
  1. Robert
    Robert avatar
    5 posts
    Member since:
    Sep 2010

    Posted 10 May 2011 Link to this post

    Using a plain RIA DomainDataSource, defined as:

    <riaControls:DomainDataSource AutoLoad="True" Name="ddsMain" QueryName="GetOffenderAliases"
                                  LoadingData="ddsMain_LoadingData" LoadedData="ddsMain_LoadedData"
                                  SubmittingChanges="ddsMain_SubmittingChanges" SubmittedChanges="ddsMain_SubmittedChanges"
                                  >
        <riaControls:DomainDataSource.DomainContext>
            <my:OASISDomainContext />
        </riaControls:DomainDataSource.DomainContext>
        <riaControls:DomainDataSource.FilterDescriptors>
            <riaControls:FilterDescriptor x:Name="fdOffenderID" PropertyPath="OffenderID" Operator="IsEqualTo" Value="0"/>
        </riaControls:DomainDataSource.FilterDescriptors>
    </riaControls:DomainDataSource>

    I can, in the code behind, successfully do something like the below to set the Value of the fdOffenderID filter descriptor.

     

     

     

     

    Private _OffenderID As Integer
    Public Property OffenderID() As Integer
        Get
            Return _OffenderID
        End Get
        Set(ByVal value As Integer)
            _OffenderID = value
        End Set
    End Property
    Public Sub LoadForOffenderID(ByVal OffenderIDNumber As Integer)
        OffenderID = OffenderIDNumber
        LoadData()
    End Sub
    Public Sub LoadData()
        Try
            fdOffenderID.Value = OffenderID
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

    However, replacing that with an "identical" RadDomainDataSource, defined as:

    <telerik:RadDomainDataSource AutoLoad="True" Name="ddsMain" QueryName="GetOffenderAliases"
                                  LoadingData="ddsMain_LoadingData" LoadedData="ddsMain_LoadedData"
                                  SubmittingChanges="ddsMain_SubmittingChanges" SubmittedChanges="ddsMain_SubmittedChanges"
                                  >
        <telerik:RadDomainDataSource.DomainContext>
            <my:OASISDomainContext />
        </telerik:RadDomainDataSource.DomainContext>
        <telerik:RadDomainDataSource.FilterDescriptors>
            <telerik:FilterDescriptor x:Name="fdOffenderID" Member="OffenderID" Operator="IsEqualTo" Value="0"/>
        </telerik:RadDomainDataSource.FilterDescriptors>
    </telerik:RadDomainDataSource>

    the set of fdOffenderID.Value at run-time throws a null reference on fdOffenderID.  I have read that you have tried to maintain full code compatability with the RIA DomainDataSource, so surely this is a bug or an oversight?

    Any assistance would be greatly appreciated.

    Thank you,

    Robert Burger
  2. Answer
    Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 11 May 2011 Link to this post

    Hello Robert,

    Our FilterDescriptorsCollection is not a DependencyObjectCollection and that is why its children, i.e. the FilterDescriptor's are not part of the visual tree. Since they are not part of the visual tree, they cannot be found by Name.

    You can find the descriptor by its Member or its index in the FilterDescriptors collection or define in code-behind so you will have a reference to it.

    I have prepared a small sample project that demonstrates these approaches. 

    Look in the Button_Click event handler.

    I hope this helps.

    All the best,
    Ross
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. Robert
    Robert avatar
    5 posts
    Member since:
    Sep 2010

    Posted 11 May 2011 Link to this post

    I knew that I could iterate through the collection, but your example is much more elegant.  With that said, I really liked that the RadDomainDataSource was a drop-in replacement for the RIA DomainDataSource.  But this difference makes that not quite true!  So, I would encourage fixing this discrepancy, which I assume also applies to SortDescriptors, etc.

    Thanks for your very quick response and solution.

    --Robert
  5. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 11 May 2011 Link to this post

    Hi Robert,

    The FilterDescriptors, SortDescriptors, etc classes were created years before RadDomainDataSource and are part of our common data engine. The collections that they reside in are not DependencyObjectCollections on by design. Making them DependencyObjectCollections is a matter of half-a-line of code (i.e. derive them from DependencyObjectCollection), but that's not what we chose for reasons which I will not go into here.

    We have never claimed that our API is 100% the same as Microsoft's. Maybe 99%, but not 100%. There are some fundamental architectural differences between the two controls (and the underlying data engines), and while we've done our best to make the top-surface API as similar as possible, there are little things that are slightly different. You've found one of them.

    I believe that you can find the FilterDescriptor in many other ways which is a feasible workaround.

    Thank you for your understanding.

    Kind regards,
    Ross
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top