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
1930
Other way to set datasource
posted

Hi

I followed the "Working With RIA Services in Silverlight (Client-Side Rendering)" to create report in my SL application.

And i put this XAML to create reportviewer and datasource.

<riaControls:DomainDataSource x:Name="domainDataSource"  
                                      AutoLoad="False"  
                                      QueryName="GetTableForIdRange">
            <riaControls:DomainDataSource.DomainContext>
                <web:MyDomainContext />
            </riaControls:DomainDataSource.DomainContext>
            <riaControls:DomainDataSource.QueryParameters >
                <riaControls:Parameter ParameterName="FromId" Value="0" />
                <riaControls:Parameter ParameterName="ToId" Value="10" />
            </riaControls:DomainDataSource.QueryParameters>
        </riaControls:DomainDataSource>
        <ig:XamReportViewer Name="xamReportViewer">
            <ig:XamReportViewer.RenderSettings>
                <ig:ClientRenderSettings x:Name="reportRenderSetting" DefinitionUri="MyProject.Report.Report1.igr, MyProject" >
                    <ig:ClientRenderSettings.DataSources>
                        <ig:DataSource x:Name="dataSourceSetting" TargetDataSource="Table"  ItemsSource="{Binding ElementName=domainDataSource}" />
                    </ig:ClientRenderSettings.DataSources>
                </ig:ClientRenderSettings>
            </ig:XamReportViewer.RenderSettings>
        </ig:XamReportViewer>

 

My question is , is possible to create all this in CodeBehind rather than XAML ???

Can't i use the datacontext, instead of the DomainDataSource to set the DomainDataSource ???

 

Thanks

byr

  • 3070
    posted

    Hi,

    Yes you can.

    There are two different things here: how you obtain the data? and how you bind it to the report? Both of them can be done programmatically.

    You can create the DomainDataSource programmatically or you can call RIA Services directly through the DomainContext. Once you choose the mechanism you will use to get the data you have to define how you will pass it to the report viewer.

    For the report viewer you can use a ViewModel approach (i.e. specifying bindings in the XAML for the report definition and/or the data sources) or you can set programmatically a new RenderSettings configuration specifying the report you want to render and the data sources you want to use.

    The DataSource.ItemsSource property should be set to the DamainDataSource you created or the data resultant of invoking RIA directly, depending on the mechanism you choose.

    Hope it helps.

    Thanks,

    Leo