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

RadDomainDataSource in code behind

6 Answers 233 Views
DomainDataSource
This is a migrated thread and some comments may be shown as answers.
Chris Thierry
Top achievements
Rank 1
Chris Thierry asked on 19 May 2011, 04:20 PM

Hi, I'm trying to use RadDomainDataSource in the code behind of a silverlight 4 application with VS2010 and RIA Services. I have a RadGridView with a RadDataPager.

In my RadGridView I'm loading diferent information, so I need to change the property QueryName each time that I change my data, now I have the code in the xaml but I want to put it in the cs file because is easier to change this property code behind.

Could you please someone tells me how to translate this code in the code behind? or if I keep the code in the xaml, where is the correct place to change QueryName and reload the grid?

<Grid x:Name="LayoutRoot">
    <Grid.Resources>
        <local:MillisecondsToTimeSpanConverter x:Key="LoadDelayConverter"/>                       
    </Grid.Resources>
      
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="26" />
        <RowDefinition Height="*" />
        <RowDefinition Height="35" />
    </Grid.RowDefinitions>       
      
    <telerik:RadNumericUpDown VerticalAlignment="Center"
        Value="500"
        Name="loadDelay" 
        IsInteger="True"
        NumberDecimalDigits="0"
        ValueFormat="Numeric"
        Visibility="Collapsed"/>
      
    <telerik:RadDomainDataSource x:Name="ddsEmployeeSelectUC"
                                 AutoLoad="True"
                                 QueryName="GetEmployee2Query"                                    
                                 LoadDelay="{Binding Value, ElementName=loadDelay, Converter={StaticResource LoadDelayConverter}}"                                     
                                 PageSize="20">
        <telerik:RadDomainDataSource.DomainContext>
            <e:EmployeeDomainContext />
        </telerik:RadDomainDataSource.DomainContext>
        <telerik:RadDomainDataSource.QueryParameters>
            <telerik:QueryParameter ParameterName="subsidiary" Value="{Binding mySubsidiary}" />
        </telerik:RadDomainDataSource.QueryParameters>
    </telerik:RadDomainDataSource>
    <Border 
        Grid.Column="0"             
        Grid.Row="0"             
        Style="{StaticResource BorderStyleCornerRadiusOnTop}">
        <Border.Background>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="#FFD1D1D1" Offset="0" />
                <GradientStop Color="#00F5FAFC" Offset="1" />
            </LinearGradientBrush>
        </Border.Background>
        <TextBlock 
            x:Name="TextBlockTitle"             
            Margin="10,10,0,5"
            Grid.Column="0"
            Grid.Row="0"            
            Style="{StaticResource ModuleTitleStyle}" />
    </Border>
      
    <Grid x:Name="gridSearch" Grid.Row="1" Grid.Column="0">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
          
        <Image 
            x:Name="imgSearch"
            Grid.Column="0"
            Margin="10,1,0,3"
            Source="/Etelesolv.Telemanager.TME;component/Assets/Images/Icons/search_icon.png" 
            Stretch="None" />
        <TextBox 
            x:Name="TextBoxSearchEmployee"
            Grid.Column="1"
            Grid.Row="0"                
            Margin="2,1,10,3"
            HorizontalAlignment="Stretch"
            />
    </Grid>                    
    <telerik:RadBusyIndicator 
        x:Name="rbiEmployeeSelectUC"
        Grid.Column="0"
        Grid.Row="2"
        IsBusy="{Binding IsBusy, ElementName=ddsEmployeeSelectUC}" >
          
        <telerik:RadGridView
            x:Name="rgvEmployeeSelect"            
            Grid.Column="0"
            Grid.Row="2" 
            Margin="10,0,10,0"
            Cursor="Hand"
            AutoGenerateColumns="False" 
            AlternateRowBackground="{StaticResource GridRowBackgroundColorBrush}"
            AlternationCount="2"                        
            CanUserFreezeColumns="False"                        
            CanUserDeleteRows="False" 
            CanUserInsertRows="False"   
            ColumnWidth="*"
            IsReadOnly="True"
            ShowGroupPanel="False"
            RowIndicatorVisibility="Collapsed"             
            HorizontalAlignment="Stretch" 
            VerticalAlignment="Stretch"
            ItemsSource="{Binding DataView, ElementName=ddsEmployeeSelectUC}" />
           
    </telerik:RadBusyIndicator>                      
    <telerik:RadDataPager 
        x:Name="dpgEmployeeSelect"            
        Grid.Column="0" 
        Grid.Row="3"
        DisplayMode="FirstLastPreviousNext"             
        VerticalAlignment="Center"
        HorizontalAlignment="Stretch"            
        Margin="10,0,10,0"
        Source="{Binding DataView, ElementName=ddsEmployeeSelectUC}" />        
</Grid>

6 Answers, 1 is accepted

Sort by
0
Chris Thierry
Top achievements
Rank 1
answered on 20 May 2011, 02:43 PM
HI,
If I use QueryableDomainServiceCollectionView in code behind, how can I bind a text box for automatic search, I know how to bind the textbox to the RadDomainDataSource in the xaml but I don't find any example of doing this in the code behind. Please I need an answer.
Thanks.
0
Nedyalko Nikolov
Telerik team
answered on 20 May 2011, 02:44 PM
Hello Chris Thierry,

Generally there is no "right" place, since RadDomainDataSource needs two properties (their values) in order to work properly DomainContext and QueryName. Setting any of these properties from code behind will cause an attempt to load (if AutoLoad is true).
 The "right" way to do that is to take advantage of ISupportInitialize interface and call radDomainDataSource.BeginInit() and radDomainDataSource.EndInit() before and after all changes. In fact this mimics what XamlParser do with xaml code.
Let me know if this doesn't help.

All the best,
Nedyalko Nikolov
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
Chris Thierry
Top achievements
Rank 1
answered on 20 May 2011, 03:04 PM
Sorry but It doesn't help me.
Now I'm using QueryableDomainServiceCollectionView in the code behind instead of RadDomainDataSource, I'm not using MVVM, I just want to know how can I bind a search text box to be able to apply a filter to my query and refresh my grid automatically.
Thank yo.
0
Chris Thierry
Top achievements
Rank 1
answered on 20 May 2011, 03:54 PM
Hi,
I need to know if this is possible. Could you please provide an example?
Thank you.
0
Chris Thierry
Top achievements
Rank 1
answered on 30 May 2011, 06:42 PM
Hi
Do you have any news?
Thank you.
0
Rossen Hristov
Telerik team
answered on 31 May 2011, 07:18 AM
Hello Chris Thierry,

The QDSCV has a property called FilterDescriptors. You can add a FilterDesciptor to it and bind its Value to your thing. In this way, each time the FilterDescriptor.Value changes, the QDSCV will automatically go to the server and fetch the filtered data. Or you can attach to your search text-box TextChanged event and manually update the FilterDescriptor.Value if you are not into this whole view-model thing.

A project that uses a QDSCV can be found on my blog post. You can use it in order to study the way the QDSCV works.

Let me know if you have any specific questions.

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
Chris Thierry
Top achievements
Rank 1
Answers by
Chris Thierry
Top achievements
Rank 1
Nedyalko Nikolov
Telerik team
Rossen Hristov
Telerik team
Share this question
or