DomainDataSource filter descriptors with combo box

3 posts, 0 answers
  1. Eric Seidel
    Eric Seidel avatar
    2 posts
    Member since:
    Apr 2010

    Posted 30 Apr 2010 Link to this post

    I'm trying to figure out if what I'm attempting is impossible or if I'm just not coding it correctly.  I am trying to do a server side filtering on a telerik combo box so that even if the data isn't loaded into the combo box(only showing 100 records) the server will still filter based on what is typed in combo box.  The filtering that the control comes with is for client side only so I thought this would get by that.  Any help would be great.  The column I'm trying to filter on is last_name(a string in code, varchar in sql server) from the domain data source. 

    Here is the error I get from my domaindatasource LoadedData method

    System.InvalidOperationException: The FilterDescriptor with its PropertyPath equal to 'last_name' cannot be evaluated. ---> System.ArgumentException: Operator 'StartsWith' incompatible with operand types 'String' and 'Object' --->
    System.InvalidOperationException: The type String does not expose a method called 'StartsWith' at
    System.Windows.Controls.LinqHelper.GetMethod(String methodName, Expression left, Expression right)
    as System.Windows.Controls.LinqHElper.GenerateMethodCall(String methodName, Expression left, Expression right)
    at System.Windows.Controls.LinqHelper.GenerateStartsWith(Expression left, Expression right)
    at System.Windows.Controls.LinqHelper.BuildFilterExpression(Expression propertyExpression, FilterOperator filterOperator, Expression valueExpression, Boolean isCaseSensitive)
    at System.Windows.Controls.LinqHelper.BuildFilterExpression(Type type, String propertyPath, FIlterOperator filterOperator, Object value, Boolean isCaseSensitive, Expression& filterExpression) -- end of inner exception stack trace

    I've tried contains and I get the same thing.  What am I doing wrong?  Thanks.

    Here is the code being used for this part:
         <riaControls:FilterDescriptor IsCaseSensitive="False" PropertyPath="last_name"   
               Value="{Binding Path=Text,ElementName=cmbParticipant}" Operator="StartsWith" >   

    and here is the combo box







       <DataTemplate x:Key="cmbParticipantItemTemplate">  
         <StackPanel Orientation="Horizontal">  
          <TextBlock Text="{Binding participant_id}"/>  
          <TextBlock Text=" - "/>  
          <TextBlock Text="{Binding last_name}" /> 
          <TextBlock Text=", "/>  
          <TextBlock Text="{Binding first_name}"/>  





    <telerikInput:RadComboBox x:Name="cmbParticipant" HorizontalAlignment="Left" Grid.Row="7"   
    Grid.Column="1" Width="238" IsEditable="True"   
    IsDropDownOpen="False" MaxDropDownHeight="200" StaysOpenOnEdit="True"   
    ItemsSource="{Binding Data, ElementName=dsParticipants}" 
    ItemTemplate="{StaticResource cmbParticipantItemTemplate}"/>  

    I've tried without using an item template as well and just displaying the last_name. 

  2. Hristo
    Hristo avatar
    832 posts

    Posted 06 May 2010 Link to this post

    Hello Eric Seidel,

    This error is related to the Text property of RadComboBox. By Default its value is null (not string empty) and DomainDataSource control cannot generate the correct LINQ because null doesn't contain StartsWith method.
    You can easily workaround this by setting the Text property to empty string. Unfortunately in Silverlight Bindings are not as powerful as in WPF and you cannot specify when this binding gets evaluated. What this mean is that when you hit a key new query will be sent immediately (Text property is updated on KeyDown). So my recommendation is to use separate TextBox and bound to its Text property (its value is string empty by default and bindings to TextBox.Text are evaluated on TextBox LostFocus event).
    ItemTemplate doesn't affect DDS. Also you should consider changing the default ItemsPanel to VirtualizingStackPanel (for better performance).

    Let us know if you need more information.

    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. Eric Seidel
    Eric Seidel avatar
    2 posts
    Member since:
    Apr 2010

    Posted 06 May 2010 Link to this post

    Thank you for the reply.  That makes perfect sense. 
Back to Top