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

How to filter dropdown list

3 Answers 338 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shailesh
Top achievements
Rank 1
Shailesh asked on 27 Feb 2012, 08:31 AM
Hi,
      I am using telerik grid in which i have used Dropdown list. I m getiing value in drop down list from another table. So what should be the filter criteria i use.
<telerik:GridDropDownColumn DataField="INSTRUMENT_ID" DataSourceID="SqlDataSource2"
                ShowFilterIcon="false" HeaderText="PRODUCT NAME" ListTextField="INSTRUMENT_NAME"
                ListValueField="INSTRUMENT_ID"  
                UniqueName="INSTRUMENT_ID" ColumnEditorID="GridDropDownListColumnEditor1">
            </telerik:GridDropDownColumn>

bt it gives me error like
No property or field 'Jeevan' exists in type 'DataRowView'


Please Reply

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 27 Feb 2012, 09:31 AM
Hello,

GridDropDownColumn is filtered by its ListValueField when the default filtering feature of the control is used. Check the following help documentation which explains more about this.
Filtering By ListTextField for GridDropDownColumn

Thanks,
Princy.
0
Shailesh
Top achievements
Rank 1
answered on 27 Feb 2012, 10:16 AM
Still I m not getting how to use it.


Basically m using inbuilt filtering functionality. I have code with me kindly help me through it.

<telerik:RadGrid ID="RadGrid1" GridLines="None" runat="server" AllowAutomaticDeletes="true"
    EnableEmbeddedSkins="true" Skin="Sunset" AllowAutomaticInserts="true" PageSize="10"
    AllowAutomaticUpdates="true" AutoGenerateColumns="false" AllowFilteringByColumn="true"
    DataSourceID="SqlDataSource1" OnItemUpdated="RadGrid1_ItemUpdated" OnItemDeleted="RadGrid1_ItemDeleted"
    OnItemInserted="RadGrid1_ItemInserted" OnDataBound="RadGrid1_DataBound">
    <PagerStyle Mode="NextPrevAndNumeric" />
  
 <MasterTableView Width="100%" CommandItemDisplay="TopAndBottom" DataKeyNames="CUSTOMER_INSTRUMENT_ID"
        DataSourceID="SqlDataSource1" HorizontalAlign="NotSet" AutoGenerateColumns="False">
        <Columns>
            <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                <ItemStyle CssClass="MyImageButton" />
            </telerik:GridEditCommandColumn>
            
            <%--<telerik:GridDropDownColumn DataField="INSTRUMENT_ID" DataSourceID="SqlDataSource2"
                AllowFiltering="true" ShowFilterIcon="true" HeaderText="PRODUCT NAME" ListTextField="INSTRUMENT_NAME"
                ListValueField="INSTRUMENT_ID" UniqueName="INSTRUMENT_ID" ColumnEditorID="GridDropDownListColumnEditor1">
            </telerik:GridDropDownColumn>--%>


            <telerik:GridDropDownColumn DataField="INSTRUMENT_ID" DataSourceID="SqlDataSource2"
                AllowFiltering="true" ShowFilterIcon="true" HeaderText="PRODUCT NAME" ListTextField="INSTRUMENT_NAME"
                ListValueField="INSTRUMENT_ID" UniqueName="INSTRUMENT_ID" ColumnEditorID="GridDropDownListColumnEditor1">
            </telerik:GridDropDownColumn>

            <telerik:GridDropDownColumn DataField="COMPANY_ID" DataSourceID="SqlDataSource3"
                HeaderText="PROVIDER COMPANY NAME" ListTextField="COMPANY_NAME"
                ListValueField="COMPANY_ID" AllowFiltering="true" ShowFilterIcon ="true"
                UniqueName="COMPANY_ID" ColumnEditorID="GridDropDownListColumnEditor1">
            </telerik:GridDropDownColumn>
          
            <telerik:GridBoundColumn DataField="OTHER_DESC" HeaderText="OTHER DESC NAME" SortExpression="OTHER_DESC"
                UniqueName="OTHER_DESC" ColumnEditorID="GridTextBoxColumnEditor1">
            </telerik:GridBoundColumn>
           
            <telerik:GridDateTimeColumn UniqueName="ISSUE_DATE" PickerType="DatePicker" HeaderText="DATE ISSUED"
                CurrentFilterFunction="Contains" DataField="ISSUE_DATE" FooterText="DateTimeColumn footer"
                DataFormatString="{0:MM/dd/yyyy}" EditDataFormatString="MMMM dd, yyyy hh:mm tt">
                <ItemStyle Width="120px" />
            </telerik:GridDateTimeColumn>

            <telerik:GridDateTimeColumn UniqueName="MATURITY_DATE" PickerType="DatePicker" HeaderText="MATURITY DATE"
                DataField="MATURITY_DATE" FooterText="DateTimeColumn footer" DataFormatString="{0:MM/dd/yyyy}"
                EditDataFormatString="MMMM dd, yyyy hh:mm tt">
                <ItemStyle Width="120px" />
            </telerik:GridDateTimeColumn>
            <telerik:GridBoundColumn DataField="VALUE" HeaderText="VALUE" SortExpression="VALUE"
                CurrentFilterFunction="Contains" AllowFiltering="true" UniqueName="VALUE" ColumnEditorID="GridTextBoxColumnEditor1">
            </telerik:GridBoundColumn>
            <telerik:GridButtonColumn ConfirmText="Delete This Column?" ConfirmDialogType="RadWindow"
                ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                UniqueName="DeletColumn">
            </telerik:GridButtonColumn>
        </Columns>
    </MasterTableView>
    <ClientSettings>
        <ClientEvents OnRowDblClick="RowDblClick" OnGridCreated="gridCreated" />
    </ClientSettings>
</telerik:RadGrid>


<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:FinancialServices %>"
    ProviderName="System.Data.SqlClient" SelectCommand="SELECT [INSTRUMENT_ID], [INSTRUMENT_NAME] FROM [INSTRUMENTS]">
</asp:SqlDataSource>

<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:FinancialServices %>"
    ProviderName="System.Data.SqlClient" SelectCommand="SELECT [COMPANY_ID], [COMPANY_NAME] FROM [INSTRUMENT_COMPANIES]">
</asp:SqlDataSource>

Please reply me if any......Please Help
0
Tsvetina
Telerik team
answered on 01 Mar 2012, 01:09 PM
Hello Shailesh,

You cannot filter the grid by a field that is not inside its datasource. So, if you want to filter by the value field but without making the user type an ID, you can use a hidden column bound to the same field as the GridDropDownColumn's value field and modify to filter command to actually filter by it. Exactly as the article linked to by Princy shows. Have you tried this approach? Do you have any specific questions about it or why does it not work for you?

Kind regards,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Shailesh
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Shailesh
Top achievements
Rank 1
Tsvetina
Telerik team
Share this question
or