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

RadDomainDataSource Load Delay

6 Answers 146 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Chris Thierry
Top achievements
Rank 1
Chris Thierry asked on 21 Jan 2011, 05:27 PM
Hi, I'm trying to user this example (http://demos.telerik.com/silverlight/#DomainDataSource/LoadDelay), trying to use a textbox and when the user write something, going to the database, filter data and bring it back to the client.

In the example, I don't find the relation between the textbox and the RadDomainDataSource. How is doing the request to the server. I don't want to use a RadNumericUpDown and RadProgressBar, I just want to use the textBox, when the user types something, execute my sp on the server.
Is there any other example?
Thank you.

6 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 24 Jan 2011, 07:34 AM
Hi,

 Have you checked the QueryParameter declaration? 

All the best,
Vlad
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Chris Thierry
Top achievements
Rank 1
answered on 24 Jan 2011, 02:55 PM
Yes, I have. this is automatic coming from RadDomainDataSource? I know that I should use AutoLoad=true, I'm doing this programatically, is there any difference if I'm doing this in the cs code?, I send you my code:

namespace RadDomainDataSource
{
    using System.Windows.Controls;
    using System.Windows.Navigation;
    using System.ServiceModel.DomainServices.Client;   
    using RadDomainDataSource.Web;
    using Telerik.Windows.Controls;
    using System.Windows;
    using System.Windows.Data;
    using System;
 
    /// <summary>
    /// Home page for the application.
    /// </summary>
    public partial class Home : Page
    {
        /// <summary>
        /// Creates a new <see cref="Home"/> instance.
        /// </summary>
        public Home()
        {
            InitializeComponent();               
            this.Title = ApplicationStrings.HomePageTitle;
            LoadEntities();
        }
 
        private void LoadEntities()
        {
            //this.rgvEmployeeSelect.Columns.Clear();
            //this.rgvEmployeeSelect.ItemsSource = null;
              
            this.rgvEmployeeSelect.Columns.Add(
                CreateGridViewDataColumn(
                   typeof(string), "FullName",
                   "Employee", string.Empty,
                   TextAlignment.Left, new GridViewLength(1, GridViewLengthUnitType.Star), TextAlignment.Left, true));
 
            DomainDataSource dds = new DomainDataSource();
 
            dds.QueryName = "GetEmployee";           
            dds.QueryParameters.Add(new Parameter { ParameterName = "Subsidiary", Value = null });
            dds.QueryParameters.Add(new Parameter { ParameterName = "Division", Value = null });
            dds.QueryParameters.Add(new Parameter { ParameterName = "Department", Value = null });
            dds.QueryParameters.Add(new Parameter { ParameterName = "ManagerSubsidiary", Value = null });
            dds.QueryParameters.Add(new Parameter { ParameterName = "ManagerDivision", Value = null });
            dds.QueryParameters.Add(new Parameter { ParameterName = "ManagerDepartment", Value = null });
            dds.QueryParameters.Add(new Parameter { ParameterName = "EmployeeID", Value = null });
            dds.QueryParameters.Add(new Parameter { ParameterName = "Admin", Value = null });
            dds.QueryParameters.Add(new Parameter { ParameterName = "Language", Value = "EN" });
            dds.QueryParameters.Add(new Parameter { ParameterName = "Search", Value = TextBoxSearch.Text });
 
            dds.DomainContext = this.context;
            dds.Name = "ddsEmployeeSelectUC";
            dds.LoadDelay = new TimeSpan(0, 0, 2);
 
            dds.LoadSize = 40;
            //dds.PageSize = 20;
            dds.AutoLoad = true;
 
            dds.Load();
            this.Resources.Remove("ddsEmployeeSelectUC");
            this.Resources.Add("ddsEmployeeSelectUC", dds);
        }
 
        public static GridViewDataColumn CreateGridViewDataColumn(
            Type columnType, string uniqueName, string header,
            string format, TextAlignment headerTextAlignment,
            GridViewLength columnWidth, TextAlignment columnAlign, bool isVisible)
        {
            GridViewDataColumn column = new GridViewDataColumn();
            column.DataType = columnType;
            column.UniqueName = uniqueName;
            column.Header = header;
            column.Width = columnWidth;
            column.HeaderTextAlignment = headerTextAlignment;
            column.TextAlignment = columnAlign;         
            return column;
        }//end of CreateGridViewDataColumn
 
        private DefaultDomainContext context = new DefaultDomainContext();
       
    }
}
 and my xaml:
<navigation:Page xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices"
    x:Class="RadDomainDataSource.Home"
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"     
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"     
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
    xmlns:myD="clr-namespace:RadDomainDataSource.Web"            
 
  <Grid x:Name="LayoutRoot">
 
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
 
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="35" />
        </Grid.RowDefinitions>       
       
        <TextBox x:Name="TextBoxSearch"                 
            Grid.Column="0"
            Grid.Row="0" />
 
            <telerik:RadGridView
                x:Name="rgvEmployeeSelect"           
                Grid.Column="0"
                Grid.Row="1"
                Margin="10,0,10,0"
                Cursor="Hand"
                AutoGenerateColumns="False"                
                AlternationCount="2"                       
                CanUserFreezeColumns="False"                       
                CanUserDeleteRows="False"
                CanUserInsertRows="False"  
                ColumnWidth="*"
                IsReadOnly="True"
                ShowGroupPanel="False"
                RowIndicatorVisibility="Collapsed"            
                HorizontalAlignment="Stretch"
                VerticalAlignment="Stretch"        
                ScrollViewer.VerticalScrollBarVisibility="Auto"             
                ItemsSource="{Binding Path=Data, ElementName=ddsEmployeeSelectUC}" />
 
        <telerik:RadDataPager
            x:Name="dpgEmployeeSelect"           
            Grid.Column="0"           
            Grid.Row="2"
            PageSize="20"
            DisplayMode="FirstLastPreviousNext"            
            VerticalAlignment="Center"
            HorizontalAlignment="Stretch"           
            Margin="10,0,10,0"
            Source="{Binding Path=Data, ElementName=ddsEmployeeSelectUC}" />
       
    </Grid>
 
</navigation:Page>

Thank you.

0
Chris Thierry
Top achievements
Rank 1
answered on 14 Feb 2011, 07:56 PM
I didn't receive any answer about this, should I create a ticket???
Thank you.
0
Rossen Hristov
Telerik team
answered on 15 Feb 2011, 08:13 AM
Hello Chris Thierry,

There was a bug with the AutoLoad functionality not triggering in certain cases, but it is fixed in the "Latest Internal Release" and the 2010 Q3 SP1 versions.

After you upgrade the only thing you need to hook up a text-box to the RDDS is the following:

<TextBox x:Name="searchTextBox" VerticalAlignment="Center" telerik:StyleManager.Theme="Office_Black" Margin="2, 2, 2, 0" Width="90"
                     TextChanged="OnSearchTextBoxTextChanged"/>
                <TextBlock VerticalAlignment="Center" Margin="2, 2, 2, 0">Load Delay (ms)</TextBlock>
                <telerik:RadNumericUpDown VerticalAlignment="Center"
                                      Value="1000"
                                      IsEditable="False"
                                      Name="loadDelayUpDown"
                                      IsInteger="True"
                                      NumberDecimalDigits="0"
                                      ValueFormat="Numeric"
                                      Minimum="0"
                                      Maximum="2000"
                                      SmallChange="100"
                                      LargeChange="1000"
                                      Margin="2, 2, 2, 0"/>
                <telerik:RadProgressBar Name="progressBar"
                                    Margin="2, 2, 2, 0"
                                    Width="410"
                                    />
            </StackPanel>
        </telerikQuickStart:HeaderedContentControl>
        <telerik:RadDomainDataSource x:Name="customersDataSource"
                                     LoadDelay="{Binding Value, ElementName=loadDelayUpDown, Converter={StaticResource LoadDelayConverter}}"
                                     AutoLoad="True"
                                     QueryName="GetCustomersWithContactNameContaining"
                                     LoadingData="OnCustomersDataSourceLoadingData">
            <telerik:RadDomainDataSource.DomainContext>
                <e:NorthwindDomainContext />
            </telerik:RadDomainDataSource.DomainContext>
            <telerik:RadDomainDataSource.QueryParameters>
                <telerik:QueryParameter ParameterName="searchString"
                                        Value="{Binding Text, ElementName=searchTextBox}"/>
            </telerik:RadDomainDataSource.QueryParameters>
        </telerik:RadDomainDataSource>

The yellow color demonstrates the link between a QueryParameter.Value and TextBox.Text. When the Value of a QueryParameter changes the AutoLogic should trigger and reload RadDomainDataSource. That is after you upgrade to the version that fixes the bug.

If after upgrading you still can't get this to work -- please prepare a very simplistic sample project that reproduces the behavior and attach it. We will examine it immediately to see what is going on.

I hope this helps.

Best wishes,
Ross
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Chris Thierry
Top achievements
Rank 1
answered on 15 Feb 2011, 03:10 PM

Yes! is working ok, I'll continue testing... one more question, in my xaml code I have more parameters, almost all parameters comes from properties of a class, how can refere to this properties from my xaml code?, here you have an example:

<telerik:RadDomainDataSource 
    x:Name="ddsEmployeeSelectUC"
    AutoLoad="True"
    QueryName="GetEmployee2Query"                                    
    PageSize="20"
    <telerik:RadDomainDataSource.DomainContext
        <e:EmployeeDomainContext /> 
    </telerik:RadDomainDataSource.DomainContext
    <telerik:RadDomainDataSource.QueryParameters
        <telerik:QueryParameter ParameterName="subsidiary" Value="{Binding ElementName=Globals.URLEntity.Subsidiary}" /> 
        <telerik:QueryParameter ParameterName="division" Value="{Binding ElementName=Globals.URLEntity.Division}" /> 
        <telerik:QueryParameter ParameterName="department" Value="{Binding ElementName=Globals.URLEntity.Department}" /> 
        <telerik:QueryParameter ParameterName="searchEmployee" Value="{Binding Text, ElementName=TextBoxSearchEmployee}" /> 
    </telerik:RadDomainDataSource.QueryParameters
</telerik:RadDomainDataSource>

I have 3 parameters with values comes from properties of a class, in my case : Global.URLEntity.Subsidiary, the value is always null but
is not true because the property has a value, How can I refer to a property of a class?
Thank you.
0
Rossen Hristov
Telerik team
answered on 16 Feb 2011, 02:27 PM
Hi Chris Thierry,

You will have to create a view model class containing all of the properties you need to bind to, no matter whether this is a query parameter value of RDDS or something completely different on the page. This view model class can serve as the DataContext for your entire page. In other words you will have to give up the ElementName-kind-of-binding, since you are no longer binding to an UI Element, i.e. a TextBox.

I have done something similar in my blog post.

The important thing to note here is that this architecture is not specific to RDDS. It is a general Silverlight / WPF pattern.

A quick search on the web for "MVVM" will return hundreds of tutorials that discuss the best practices when implementing the Model-View-ViewModel pattern.

I hope this helps. Let me know if you have any other questions.

Greetings,
Ross
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
GridView
Asked by
Chris Thierry
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Chris Thierry
Top achievements
Rank 1
Rossen Hristov
Telerik team
Share this question
or