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

DomainDataSource filter descriptors with combo box

2 Answers 112 Views
This is a migrated thread and some comments may be shown as answers.
Eric Seidel
Top achievements
Rank 1
Eric Seidel asked on 30 Apr 2010, 08:34 PM
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 Answers, 1 is accepted

Sort by
Telerik team
answered on 06 May 2010, 10:03 AM
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.
Eric Seidel
Top achievements
Rank 1
answered on 06 May 2010, 12:09 PM
Thank you for the reply.  That makes perfect sense. 
Asked by
Eric Seidel
Top achievements
Rank 1
Answers by
Telerik team
Eric Seidel
Top achievements
Rank 1
Share this question