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

Filtering on foreign key columns not working

4 Answers 162 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Darren
Top achievements
Rank 2
Darren asked on 26 Jan 2009, 09:57 AM
Morning,
My foreign key columns are not filtering.
I get this error: "Expression expected".
Furthermore none of the foreign key columns have the "Contains" filter option.
The WebsiteUrl column has "Contains" filter option and works perfectly.

My columns look like this:
        <telerik:GridBoundColumn DataField="WebsiteId" DataType="System.Int64"  
            EmptyDataText="&amp;nbsp;" HeaderText="WebsiteId" ReadOnly="True"  
            SortExpression="WebsiteId" UniqueName="WebsiteId" Visible="false" ForceExtractValue="InEditMode"
        </telerik:GridBoundColumn> 
         
        <telerik:GridBoundColumn DataField="WebsiteUrl" EmptyDataText="&amp;nbsp;"  
            HeaderText="WebsiteUrl" SortExpression="WebsiteUrl" UniqueName="WebsiteUrl"
        </telerik:GridBoundColumn> 
                 
            <telerik:GridTemplateColumn HeaderText="Client" 
                DataType="System.Int64" UniqueName="Client" > 
                    <EditItemTemplate> 
                        <telerik:RadComboBox ID="RadComboBoxClientName" Runat="server"  
                            DataSourceID="LinqDataSourceClient" DataTextField="ClientName"  
                            DataValueField="ClientId" SelectedValue='<%# Bind("ClientId") %>'  
                            Skin="Vista" Width="280px"
                            <CollapseAnimation Duration="200" Type="OutQuint" /> 
                        </telerik:RadComboBox>                         
                    </EditItemTemplate> 
                     
                    <ItemTemplate> 
                         
                        <asp:Label ID="LabelClientName" runat="server" Text<%#Eval("tblClient.ClientName")%>         > </asp:Label> 
                         
                    </ItemTemplate> 
                </telerik:GridTemplateColumn>         
        
            <telerik:GridTemplateColumn HeaderText="Server" 
                DataType="System.Int32" UniqueName="Server"  > 
                    <EditItemTemplate> 
                        <telerik:RadComboBox ID="RadComboBoxServerName" Runat="server"  
                            DataSourceID="LinqDataSourceServer" DataTextField="ServerName"  
                            DataValueField="ServerId" SelectedValue='<%# Bind("ServerId") %>'  
                            Skin="Vista" Width="280px"
                            <CollapseAnimation Duration="200" Type="OutQuint" /> 
                        </telerik:RadComboBox>                         
                    </EditItemTemplate> 
                     
                    <ItemTemplate> 
                         
                        <asp:Label ID="LabelServerName" runat="server" Text<%#Eval("tblServer.ServerName")%></asp:Label> 
                         
                    </ItemTemplate> 
                </telerik:GridTemplateColumn>            
         
 
        <telerik:GridBoundColumn DataField="LogFilePath" EmptyDataText="&amp;nbsp;"  
            HeaderText="LogFilePath" SortExpression="LogFilePath"  
            UniqueName="LogFilePath" Display="False"
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn DataField="BandWidthCost" DataType="System.Decimal"  
            EmptyDataText="&amp;nbsp;" HeaderText="BandWidthCost"  
            SortExpression="BandWidthCost" UniqueName="BandWidthCost" Visible="false"
        </telerik:GridBoundColumn> 
I've Specified the filter menu manually like this:
    protected void RadGrid1_Init(object sender, EventArgs e) 
    { 
 
        GridFilterMenu menu = RadGrid1.FilterMenu; 
        int i = 0; 
        while (i < menu.Items.Count) 
        { 
            if (menu.Items[i].Text == "NoFilter" || 
               menu.Items[i].Text == "Contains" || 
               menu.Items[i].Text == "EqualTo" || 
               menu.Items[i].Text == "GreaterThan" || 
               menu.Items[i].Text == "LessThan"
            { 
                i++; 
            } 
            else 
            { 
                menu.Items.RemoveAt(i); 
            } 
        } 
 
    } 

4 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 26 Jan 2009, 10:32 AM
Hello Darren,

I reviewed the code snippet and it looks correct.
If the issue persists at your end, you can open a formal support ticket, and send us the problematic code, in the form of a small project, for further investigation.

Kind regards,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
peter
Top achievements
Rank 1
answered on 26 Jan 2009, 11:13 AM
thanks i've opened up a ticket.
0
Scott Marx
Top achievements
Rank 1
answered on 13 Apr 2011, 11:21 PM
Was there every a solution for this situation?
0
Martin
Telerik team
answered on 19 Apr 2011, 08:34 AM
Hello Scott Marx,

Here are some quotes from the support ticket responses my colleagues have provided:

"... I have noticed that the template columns are missing datafield property value. This property is needed in order RadGrid to map which property of its datasource maps to a given column. Thus please set an appropriate value and try if this helps. 

As to your other question the Contains filter option is applicable on for string value, thus it is automatically omitted from filter option when filtering on numeric values."

"... Can you please try removing the DataType or set it to tblClient.ClientName's return type from the column's declaration similar to the following:"

<telerik:GridTemplateColumn HeaderText="Client"
UniqueName="Client" DataType="System.String" DataField="tblClient.ClientName"
    <EditItemTemplate>
        <telerik:RadComboBox ID="RadComboBoxClientName" Runat="server"  
            DataSourceID="LinqDataSourceClient" DataTextField="ClientName"  
            DataValueField="ClientId" SelectedValue='<%# Bind("ClientId") %>'  
            Skin="Vista" Width="280px"> 
            <CollapseAnimation Duration="200" Type="OutQuint" />
        </telerik:RadComboBox>                         
    </EditItemTemplate>
       
    <ItemTemplate>
           
        <asp:Label ID="LabelClientName" runat="server" Text= <%#Eval("tblClient.ClientName")%>> </asp:Label>
           
    </ItemTemplate>
</telerik:GridTemplateColumn>

I hope this helps.

All the best,
Martin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
Darren
Top achievements
Rank 2
Answers by
Yavor
Telerik team
peter
Top achievements
Rank 1
Scott Marx
Top achievements
Rank 1
Martin
Telerik team
Share this question
or