Adding filter to GridDropDownColumn on Insert

3 posts, 0 answers
  1. Shivek
    Shivek avatar
    2 posts
    Member since:
    Oct 2015

    Posted 24 Nov 2016 Link to this post

    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. Eyup
    Admin
    Eyup avatar
    3740 posts

    Posted 29 Nov 2016 Link to this post

    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.
  3. Shivek
    Shivek avatar
    2 posts
    Member since:
    Oct 2015

    Posted 06 Dec 2016 in reply to Eyup Link to this post

    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.

     

    Hello Eyup,

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

    Best Regards

Back to Top