Get Filter Values

3 posts, 0 answers
  1. Eric Klein
    Eric Klein avatar
    183 posts
    Member since:
    Aug 2009

    Posted 11 Jul 2011 Link to this post

    I have a screen that contains a Radgrid.  In this radgrid I have three filterTemplates that use a Radcombobox, and a GridNumericColumn for filtering.

    It works fine when I filter on only one column but when I try want to filter by more than one it only filters on the current column.  I have changed the code behind to save the current filter and add the changes to it, the problem is I need to remove the existing filter and rebuild it based on the values from the selected filters.

    <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" EnableLinqExpressions="false"
                        PageSize="25" AutoGenerateColumns="False" GridLines="None" AllowSorting="True"
                        AllowFilteringByColumn="true" AlternatingItemStyle-BackColor="#eeeeee" ShowStatusBar="True"
                        OnItemCreated="RadGrid1_ItemCreated" OnPreRender="RadGrid1_PreRender" OnNeedDataSource="RadGrid1_NeedDataSource"
                        OnItemDataBound="RadGrid1_ItemDataBound" OnInsertCommand="RadGrid1_InsertCommand"
                        OnUpdateCommand="RadGrid1_UpdateCommand" Width="100%">
                        <PagerStyle AlwaysVisible="true" Mode="NextPrevAndNumeric" />
                        <MasterTableView CommandItemDisplay="Top" DataKeyNames="AuditID" EditMode="InPlace">
                            <AlternatingItemStyle BackColor="#EEEEEE"></AlternatingItemStyle>
                            <Columns>
                                <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" HeaderStyle-Width="50px" />
                                <telerik:GridTemplateColumn HeaderText="Branch" DataField="CRDBranchNumber" SortExpression=""
                                    UniqueName="CRDBranchNumber" HeaderStyle-Width="160px">
                                    <FilterTemplate>
                                        <telerik:RadComboBox ID="rcbBranch" DataTextField="CRDBranchNumber" DataValueField="CRDBranchNumber"
                                            AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("CRDBranchNumber").CurrentFilterValue %>'
                                            runat="server" AutoPostBack="true" OnSelectedIndexChanged="BranchCombo_SelectedIndexChanged" />
                                    </FilterTemplate>
                                    <ItemTemplate>
                                        <asp:Label runat="server" ID="lbCRDBranchNumber" Text='<%# Eval("CRDBranchNumber") %>' />
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <telerik:RadComboBox ID="rcbCRDBranchNumber" DataTextField="CRDBranchNumber" DataValueField="CRDBranchNumber"
                                            runat="server" Width="115px" />
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="rcbCRDBranchNumber"
                                            ErrorMessage="*" runat="server" ToolTip="Branch is Required" InitialValue="Select Branch"
                                            ForeColor="Red" />
                                        <asp:Label runat="server" ID="ldID" Visible="false" Text='<%# Eval("CRDBranchNumber") %>' />
                                    </EditItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn HeaderText="Auditor" DataField="AuditorName" SortExpression=""
                                    UniqueName="AuditorName" HeaderStyle-Width="225px">
                                    <FilterTemplate>
                                        <telerik:RadComboBox ID="rcbAuditor" DataTextField="AuditorName" DataValueField="AuditorName"
                                            AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("AuditorName").CurrentFilterValue %>'
                                            runat="server" AutoPostBack="true" OnSelectedIndexChanged="AuditorCombo_SelectedIndexChanged" />
                                    </FilterTemplate>
                                    <ItemTemplate>
                                        <asp:Label runat="server" ID="lbAuditor" Text='<%# Eval("AuditorName") %>' />
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <telerik:RadComboBox ID="rcbAuditor" DataTextField="AuditorName" DataValueField="AuditorID"
                                            runat="server" Width="175px" />
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="rcbAuditor"
                                            ErrorMessage="*" runat="server" ToolTip="Auditor is Required" InitialValue="Select Auditor"
                                            ForeColor="Red" />
                                        <asp:Label runat="server" ID="ldAuditorID" Visible="false" Text='<%# Eval("AuditorID") %>' />
                                    </EditItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridNumericColumn DataField="AuditYear" HeaderText="Audit Year" SortExpression="AuditYear"
                                    UniqueName="AuditYear" DataType="System.Decimal" DataFormatString="{0:F0}" />
                                <telerik:GridDateTimeColumn SortExpression="ScheduledDate" DataField="ScheduledDate"
                                    HeaderText="Scheduled" DataType="System.DateTime" DataFormatString="{0:MM/dd/yyyy}"
                                    AllowFiltering="false" HeaderStyle-Width="100px" UniqueName="ScheduledDate" />
                                <telerik:GridDateTimeColumn SortExpression="CompletedDate" DataField="CompletedDate"
                                    HeaderText="Completed" DataType="System.DateTime" DataFormatString="{0:MM/dd/yyyy}"
                                    AllowFiltering="false" HeaderStyle-Width="100px" UniqueName="CompletedDate" />
                                <telerik:GridTemplateColumn HeaderText="Status" DataField="Status" SortExpression=""
                                    UniqueName="Status" HeaderStyle-Width="195px">
                                    <FilterTemplate>
                                        <telerik:RadComboBox ID="rcbStatus" DataTextField="Status" DataValueField="Status"
                                            AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("Status").CurrentFilterValue %>'
                                            runat="server" AutoPostBack="true" OnSelectedIndexChanged="StatusCombo_SelectedIndexChanged" />
                                    </FilterTemplate>
                                    <ItemTemplate>
                                        <asp:Label runat="server" ID="lblStatus" Text='<%# Eval("Status") %>' />
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <telerik:RadComboBox ID="rcbStatus" DataTextField="Status" DataValueField="AuditStatusID"
                                            runat="server" Width="150px" />
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" ControlToValidate="rcbStatus"
                                            ErrorMessage="*" runat="server" ToolTip="Status is Required" InitialValue="Select Status"
                                            ForeColor="Red" />
                                        <asp:Label runat="server" ID="lbAuditStatusID" Visible="false" Text='<%# Eval("AuditStatusID") %>' />
                                    </EditItemTemplate>
                                </telerik:GridTemplateColumn>
                            </Columns>
                            <EditFormSettings>
                                <EditColumn InsertText="Insert Audit" UpdateText="Update Audit" UniqueName="EditCommandColumn1"
                                    CancelText="Cancel edit">
                                </EditColumn>
                            </EditFormSettings>
                        </MasterTableView>
                    </telerik:RadGrid>

    Is there a way I can iterate through the columns, get the values of the selected filter and build a filter string.
  2. Eric Klein
    Eric Klein avatar
    183 posts
    Member since:
    Aug 2009

    Posted 11 Jul 2011 Link to this post

    I have written some code that looks at the FilterExpression and I edit it by removing parts of the filter based on what filter was selected and it appears to work but  I found that when I filter by the GridNumericColumn that it losee the manually built filter.  Is there a way to mix the two or do yo need to chose one or the other?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Genti
    Admin
    Genti avatar
    107 posts

    Posted 14 Jul 2011 Link to this post

    Hello Eric Klein,

    Yes, it is possible.
    Consider the following examples that merge both types of filtering:
    Template Column filtering
    Filter Templates



    Regards,
    Genti
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Back to Top