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

Named FilterDescriptor not accessible?

3 Answers 99 Views
DomainDataSource
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 10 May 2011, 08:52 PM

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

3 Answers, 1 is accepted

Sort by
0
Accepted
Rossen Hristov
Telerik team
answered on 11 May 2011, 09:28 AM
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
0
Robert
Top achievements
Rank 1
answered on 11 May 2011, 04:29 PM
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
0
Rossen Hristov
Telerik team
answered on 11 May 2011, 05:37 PM
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
Tags
DomainDataSource
Asked by
Robert
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Robert
Top achievements
Rank 1
Share this question
or