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

Show combobox on grid filter by id but display value

1 Answer 68 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Eric Klein
Top achievements
Rank 1
Eric Klein asked on 30 Jan 2012, 05:06 PM
I have a radgrid which has a GridBoundCoulmn with a FilterTemplate.  In the Template I have ClientID and ClientName.  The ComboBox displays the Client names and when the user selects it filters based on the ClientID.  The issue I have is in order to get this to work I have to set the Bound Coulmns DataField to the ClientID, which means in the grid you see the ID and not the client name.  How do I display the Client Name in the grid.

<telerik:GridBoundColumn SortExpression="ClientID" DataField="ClientID" HeaderText="Client Name"  >
  <FilterTemplate>
     <telerik:RadComboBox ID="RadComboBoxClientName" DataTextField="ClientName" DataValueField="ClientID"
              AppendDataBoundItems="true" Width="150px" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("ClientID").CurrentFilterValue %>'
              runat="server" OnClientSelectedIndexChanged="ClientNameIndexChanged" Skin="Office2007">
     </telerik:RadComboBox>
     <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
         <script type="text/javascript">
            function ClientNameIndexChanged(sender, args) {                                                         
              var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
              if (args.get_item().get_value() == 0) {
                 tableView.filter("ClientID", args.get_item().get_value(), "NoFilter");
              }
              else {
                 tableView.filter("ClientID", args.get_item().get_value(), "EqualTo");
              }
            }
         </script>
     </telerik:RadScriptBlock>
 </FilterTemplate>
 <ItemStyle VerticalAlign="Top" />
</telerik:GridBoundColumn>

1 Answer, 1 is accepted

Sort by
0
Eric Klein
Top achievements
Rank 1
answered on 30 Jan 2012, 05:17 PM
Nevermind, I figured it out.  I just added a BoundColumn that contained the ID and set display to False and it works fine.  THought of that idea about 5 min after my post.
Tags
Grid
Asked by
Eric Klein
Top achievements
Rank 1
Answers by
Eric Klein
Top achievements
Rank 1
Share this question
or