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

Adding filter to GridDropDownColumn on Insert

2 Answers 197 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shivek
Top achievements
Rank 1
Shivek asked on 24 Nov 2016, 06:45 AM

Hi all,

 

I've managed to add a filter on a dropdown column in my grid, which allows me to easily look for the correct data in my list. But the issue here is that I cannot filter the list with the filter option "Contains". It always returns me the "EqualTo" values. I need it to work with Contains.

Here is my code:

<telerik:RadGrid ID="GridOffences" runat="server" DataSourceID="GETOffence" RenderMode="Auto" AutoGenerateColumns="False" ShowFooter="true" OnItemDataBound="GridOffences_ItemDataBound" OnItemCommand="GridOffences_ItemCommand" OnUpdateCommand="GridOffences_UpdateCommand" OnInsertCommand="GridOffences_InsertCommand">
 
    <MasterTableView AutoGenerateColumns="False" DataKeyNames="offId" CommandItemDisplay="Top" CommandItemSettings-AddNewRecordText="Add Offence" AllowSorting="false">
        <CommandItemSettings ShowAddNewRecordButton="true" ShowRefreshButton="false"
                                                        ShowExportToCsvButton="false" ShowExportToExcelButton="false" ShowExportToPdfButton="false" ShowExportToWordButton="false" />
        <EditFormSettings>
            <EditColumn UniqueName="EditColumnColumn" ButtonType="PushButton" EditText="Edit" CancelText="Cancel" InsertText="Add" UpdateText="Save"></EditColumn>
        </EditFormSettings>
        <Columns>
            <telerik:GridDropDownColumn DataSourceID="GETOffenceList" ListTextField="offName" ListValueField="offListId"
                UniqueName="offNameList" HeaderText="Offence" DataField="offListId"
                AllowAutomaticLoadOnDemand="true" DropDownControlType="RadComboBox"
                AllowVirtualScrolling="true" ShowMoreResultsBox="true" ItemsPerRequest="10">
                <ColumnValidationSettings EnableRequiredFieldValidation="true" EnableModelErrorMessageValidation="true">
                    <RequiredFieldValidator ForeColor="Red" ErrorMessage="This field is required"></RequiredFieldValidator>
                    <ModelErrorMessage BackColor="Red" />
                </ColumnValidationSettings>
                <FilterTemplate>
                    <telerik:RadComboBox ID="RadCbox_File" runat="server" DataSourceID="GETOffenceList" DataTextField="offName"
                                DataValueField="offListId" Filter="Contains"
                                AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("offListId").CurrentFilterValue %>'
                                OnClientSelectedIndexChanged="FileComboIndexChanged">
                        <Items>
                            <telerik:RadComboBoxItem Text="Select an Offence" />
                        </Items>
                    </telerik:RadComboBox>
                    <telerik:RadScriptBlock ID="RadScriptFiles" runat="server">
                        <script type="text/javascript">
                            function FileComboIndexChanged(sender, args) {
                                var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                tableView.filter("offListId", args.get_item().get_value(), "Contains");
                            }
                        </script>
                    </telerik:RadScriptBlock>
                </FilterTemplate>
            </telerik:GridDropDownColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

 

Thanks in advance for your help

2 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 29 Nov 2016, 08:27 AM
Hi Ouzayr,

Make sure that you are using the latest release version of the controls. Also, you can set the CurrentFilterFunction property of the column to Contains.

I suppose you want to achieve something similar to the implementation demonstrated in the following live sample:
http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/filtering/filter-templates/defaultcs.aspx

You can also examine the first web site from this post:
http://www.telerik.com/forums/how-to-persist-dropdownlist-selected-index-and-value-on-postback-from-radgrid-filtertemplate#GW3MyQLmVEmy8XzsmrHzeQ

I hope this will prove helpful.


Regards,
Eyup
Telerik by Progress
Telerik UI for ASP.NET AJAX is ready for Visual Studio 2017 RC! Learn more.
0
Shivek
Top achievements
Rank 1
answered on 06 Dec 2016, 06:43 AM
[quote]Eyup said:Hi Ouzayr,

Make sure that you are using the latest release version of the controls. Also, you can set the CurrentFilterFunction property of the column to Contains.

I suppose you want to achieve something similar to the implementation demonstrated in the following live sample:
http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/filtering/filter-templates/defaultcs.aspx

You can also examine the first web site from this post:
http://www.telerik.com/forums/how-to-persist-dropdownlist-selected-index-and-value-on-postback-from-radgrid-filtertemplate#GW3MyQLmVEmy8XzsmrHzeQ

I hope this will prove helpful.


Regards,
Eyup
Telerik by Progress
Telerik UI for ASP.NET AJAX is ready for Visual Studio 2017 RC! Learn more.

[/quote]

 

Hello Eyup,

Thank you for your response. I've finally added the filter on server side.

Best Regards

Tags
Grid
Asked by
Shivek
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Shivek
Top achievements
Rank 1
Share this question
or