2014-10-08 242 views
0

我正在使用telerik radgrid製作應用程序。其中一列設置爲模板列:Telerik RadGrid過濾器

<telerik:GridTemplateColumn DataField="CustomerID" DataType="System.Int32" FilterControlAltText="Filter CustomerID column" HeaderText="Customer" SortExpression="CustomerID" UniqueName="CustomerID"> 
           <InsertItemTemplate> 
            <asp:DropDownList ID="ddlInsertCustomer" runat="server" DataSourceID="SqlDataCustomers" DataTextField="customerName" DataValueField="id" SelectedValue='<%# Bind("CustomerID") %>'> 
            </asp:DropDownList> 
           </InsertItemTemplate> 
           <EditItemTemplate> 
            <asp:DropDownList ID="ddlCustomer" runat="server" DataSourceID="SqlDataCustomers" DataTextField="customerName" DataValueField="id" SelectedValue='<%# Bind("CustomerID") %>'> 
            </asp:DropDownList> 
           </EditItemTemplate> 
           <ItemTemplate> 
            <asp:Label ID="CustomerIDLabel" runat="server" Text='<%# Eval("CustomerID") %>'></asp:Label> 
           </ItemTemplate> 
          </telerik:GridTemplateColumn> 

在上我這個專欄的文字設置爲我通過LINQ查詢到一個單獨的表中獲取客戶的名稱數據綁定的後端。

問題是在我試圖過濾表的過濾器期望的id而不是名稱。有誰知道如何過濾列中的文本而不是值?

回答

0

也許你最簡單的選擇是在網格的數據源中包含所需的字段,以便它可以自動進行過濾:http://www.telerik.com/help/aspnet-ajax/grid-implementing-filtering-for-gridtemplatecolumns.html。本文還提供了一個可以查看的定製方法。

如果您在下拉列表中具有所需的數據(例如,作爲其值字段),您也可以嘗試在客戶端上添加過濾器表達式,但我不確定這適用於模板列:http://www.telerik.com/help/aspnet-ajax/grid-client-side-binding-adding-sort-filter-expressions.html