Detail Table Filter Template

2 posts, 0 answers
  1. Oliver
    Oliver avatar
    6 posts
    Member since:
    Jun 2017

    Posted 31 Jul 2017 Link to this post

    I don't know how this has been missed in the documentation. Alternatively, it's well hidden in some obscure place. I'm trying to filter a column of a detail table using a static radcombobox. Using the instructions from the "Filter Template" documentation (http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/functionality/filtering/filter-template) I'm not seeing any filtering in action on the detail table. The documentation for "Detail Tables Filtering" is rather useless (http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/functionality/filtering/detail-tables-filtering).

    Someone show me where I'm going wrong?

    <telerik:RadGrid ID="rgdepots" runat="server"
    AutoGenerateColumns="False"
    DataSourceID="depots"
    AllowFilteringByColumn="True"
    AllowSorting="True" Height="900px"
    OnItemDataBound="rgdepots_ItemDataBound" EnableLinqExpressions="false">
    <GroupingSettings CollapseAllTooltip="Collapse all groups"></GroupingSettings>
    <ClientSettings>
    <Scrolling AllowScroll="True" UseStaticHeaders="True" />
    </ClientSettings>
    <MasterTableView DataKeyNames="dID" DataSourceID="depots">
    <DetailTables>
    <telerik:GridTableView runat="server"
    Name="rgIncidents"
    AllowAutomaticInserts="true"
    AllowAutomaticUpdates="True"
    DataKeyNames="iID"
    DataSourceID="sql"
    EditMode="PopUp"
    AutoGenerateColumns="False"
    AllowPaging="True"
    PageSize="30"
    CommandItemDisplay="Top" EditFormSettings-FormMainTableStyle-Width="480px" EditFormSettings-FormStyle-Width="490px">
    <EditFormSettings EditFormType="Template">
    <FormTemplate>
    <table>
    <tr><td>Date</td><td><telerik:RadDatePicker ID="iDatePick" runat="server" DbSelectedDate='<%# Bind("iDate") %>'></telerik:RadDatePicker></td></tr>
    <tr><td colspan="3" style="text-align: center; border-bottom: 1px solid black;">Forms</td></tr>
    <tr style="text-align: center;"><td>Notification</td><td>Accident</td><td>Interview</td></tr>
    <tr style="text-align: center;">
    <td><telerik:RadCheckBox ID="chkNotification" runat="server" Checked='<%# Bind("iNotificationForm") %>'></telerik:RadCheckBox></td>
    <td><telerik:RadCheckBox ID="chkAccident" runat="server" Checked='<%# Bind("iAccidentForm") %>'></telerik:RadCheckBox></td>
    <td><telerik:RadCheckBox ID="chkInterview" runat="server" Checked='<%# Bind("iInterviewForm") %>'></telerik:RadCheckBox></td>
    </tr>
    <tr>
    <td>Damage to</td>
    <td><telerik:RadCheckBox ID="chkClarkeDamage" runat="server" Text="Clarkes" Checked='<%# Bind("iDamageClarkes") %>'></telerik:RadCheckBox></td>
    <td><telerik:RadCheckBox ID="chkOtherDamage" runat="server" Text="3rd Party" Checked='<%# Bind("iDamageThirdParty") %>'></telerik:RadCheckBox></td>
    </tr>
    <tr>
    <td>Repaired by</td>
    <td><telerik:RadCheckBox ID="chkClarkeRepair" runat="server" Text="Clarkes" Checked='<%# Bind("iRepairedClarkes") %>'></telerik:RadCheckBox></td>
    <td><telerik:RadCheckBox ID="chkOtherRepair" runat="server" Text="3rd Party" Checked='<%# Bind("iRepairedThirdParty") %>'></telerik:RadCheckBox></td>
    </tr>
    <tr>
    <td>Costs</td>
    <td>Estimated <telerik:RadTextBox ID="txtEstCost" runat="server" Text='<%# Bind("iEstimate") %>'></telerik:RadTextBox></td>
    <td>Actual <telerik:RadTextBox ID="txtActualCost" runat="server" Text='<%# Bind("iClarkesCost") %>'></telerik:RadTextBox></td>
    </tr>
    <tr><td>Costs Paid</td><td><telerik:RadCheckBox ID="chkPaid" runat="server" Checked='<%# Bind("iNotificationForm") %>'></telerik:RadCheckBox></td></tr>
    <tr><td>Location</td><td colspan="2"><telerik:RadTextBox ID="txtLocation" runat="server" Width="320px" Text='<%# Bind("iLocation") %>'></telerik:RadTextBox></td></tr>
    <tr><td>Description</td><td colspan="2"><telerik:RadTextBox ID="txtDescription" runat="server" Text='<%# Bind("iDescription") %>' TextMode="MultiLine" Width="320px"></telerik:RadTextBox></td></tr>
    <tr>
    <td>Driver</td>
    <td><telerik:RadCheckBox ID="chkAware" runat="server" Text="Aware" Checked='<%# Bind("iDriverAware") %>'></telerik:RadCheckBox></td>
    <td><telerik:RadCheckBox ID="chkFault" runat="server" Text="At Fault" Checked='<%# Bind("iDriverFault") %>'></telerik:RadCheckBox></td>
    </tr>
    <tr><td>AJG Reference</td><td><telerik:RadTextBox ID="txtAJG" runat="server" Text='<%# Bind("iAJGRef") %>'></telerik:RadTextBox></td></tr>
    <tr><td>Depot</td><td><telerik:RadDropDownList ID="txtFK1dID" runat="server" DataSourceID="depots" DataTextField="dCode" DataValueField="dID" SelectedValue='<%# Bind("fk1_dID") %>'></telerik:RadDropDownList></td></tr>
    <tr><td><telerik:RadDropDownList ID="rgEddlDriver"runat="server" DataSourceID="sqlDriver" SelectedValue='<%# Bind("fk2_dID") %>' DataTextField="dName" DataValueField="dID" AppendDataBoundItems="true"><Items><telerik:DropDownListItem Value="-1" Text="Select One" /></Items></telerik:RadDropDownList></td>
    <td><telerik:RadDropDownList ID="rgEddlCab" runat="server" DataSourceID="sqlCab" SelectedValue='<%# Bind("fk3_cID") %>'  DataTextField="cReg" DataValueField="cID" AppendDataBoundItems="true"><Items><telerik:DropDownListItem Value="-1" Text="Select One" /></Items></telerik:RadDropDownList></td>
    <td><telerik:RadDropDownList ID="rgEddlTrailer" runat="server" DataTextField="tRef" DataValueField="tID" AppendDataBoundItems="true"><Items><telerik:DropDownListItem Value="-1" Text="Select One" /></Items></telerik:RadDropDownList></td>
    </tr>
    <tr>
    <td><asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'></asp:Button></td>
    <td> </td>
    <td><asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel"></asp:Button></td>
    </tr>
    </table>
    </FormTemplate>
    </EditFormSettings>
    <ParentTableRelation>
    <telerik:GridRelationFields DetailKeyField="fk1_dID" MasterKeyField="dID" />
    </ParentTableRelation>
    <Columns>
    <telerik:GridEditCommandColumn></telerik:GridEditCommandColumn>
    <telerik:GridTemplateColumn DataField="iID" DataType="System.Int32" FilterControlAltText="Filter iID column" HeaderText="ID" ReadOnly="True" SortExpression="iID" UniqueName="iID" ForceExtractValue="Always">
    <FilterTemplate>
    </FilterTemplate>
    <ItemTemplate>
    <asp:Label ID="lblID" runat="server" Text='<%# string.Format("{0:00#}",Eval("iID")) %>'></asp:Label>/<asp:Label ID="lblDate" runat="server" Text='<%# string.Format("{0:yyyy}",Eval("iDate")) %>'></asp:Label>
    </ItemTemplate>
    </telerik:GridTemplateColumn>
    <telerik:GridBoundColumn DataField="iDate" DataType="System.DateTime" FilterControlAltText="Filter iDate column" HeaderText="Date" SortExpression="iDate" UniqueName="iDate" DataFormatString="{0:d}" ForceExtractValue="Always">
    <FilterTemplate>
    <table>
    <tr><td>From</td><td><telerik:RadDateInput ID="fDateFrom" runat="server" Width="80"></telerik:RadDateInput></td></tr>
    <tr><td>To</td><td><telerik:RadDateInput ID="fdateTo" runat="server" Width="80"></telerik:RadDateInput></td></tr>
    </table>
    </FilterTemplate>
    </telerik:GridBoundColumn>
    <telerik:GridCheckBoxColumn AllowFiltering="false" EnableHeaderContextMenu="false" ReadOnly="false" DataField="iNotificationForm" DataType="System.Boolean" HeaderText="Notification Form" UniqueName="iNotificationForm" ForceExtractValue="Always">
    </telerik:GridCheckBoxColumn>
    <telerik:GridCheckBoxColumn DataField="iInterviewForm" AllowFiltering="false" DataType="System.Boolean" FilterControlAltText="Filter iInterviewForm column" HeaderText="Interview Form" SortExpression="iInterviewForm" UniqueName="iInterviewForm" ForceExtractValue="Always">
    </telerik:GridCheckBoxColumn>
    <telerik:GridCheckBoxColumn DataField="iAccidentForm" AllowFiltering="false" DataType="System.Boolean" FilterControlAltText="Filter iAccidentForm column" HeaderText="Accident Form" SortExpression="iAccidentForm" UniqueName="iAccidentForm" ForceExtractValue="Always">
    </telerik:GridCheckBoxColumn>
    <telerik:GridTemplateColumn HeaderText="Damage" UniqueName="iDamageClarkes" ForceExtractValue="Always">
    <FilterTemplate>
    <telerik:RadTextBox ID="fTxtDamage" runat="server" Width="60"></telerik:RadTextBox>
    </FilterTemplate>
    <ItemTemplate>
    <asp:Label ID="lblDamage" runat="server" Text='<%# Eval("iDamageClarkes").ToString() == "True" ? Eval("iDamageThirdParty").ToString() == "True" ? "Clarkes, Third Party" : "Clarkes" : Eval("iDamageThirdParty").ToString() == "True" ? "Third Party" : ""%>'></asp:Label>
    </ItemTemplate>
    </telerik:GridTemplateColumn>
    <telerik:GridTemplateColumn DataField="iRepairedClarkes" DataType="System.Boolean" FilterControlAltText="Filter iRepairedClarkes column" HeaderText="Repaired by" SortExpression="iRepairedClarkes" UniqueName="iRepairedClarkes" ForceExtractValue="Always">
    <FilterTemplate>
    <telerik:RadTextBox ID="fTxtRepaired" runat="server" Width="60"></telerik:RadTextBox>
    </FilterTemplate>
    <ItemTemplate>
    <asp:Label ID="lblRepairs" runat="server" Text='<%# Eval("iRepairedClarkes").ToString() == "True" ? Eval("iRepairedThirdParty").ToString() == "True" ? "Clarkes, Third Party" : "Clarkes" : Eval("iRepairedThirdParty").ToString() == "True" ? "Third Party" : ""%>'></asp:Label>
    </ItemTemplate>
    </telerik:GridTemplateColumn>
    <telerik:GridBoundColumn DataField="iEstimate" DataType="System.Decimal" FilterControlAltText="Filter iEstimate column" HeaderText="Estimate" SortExpression="iEstimate" UniqueName="iEstimate" ForceExtractValue="Always">
    <FilterTemplate>
    <telerik:RadTextBox ID="fTxtEstimate" runat="server" Width="80"></telerik:RadTextBox>
    </FilterTemplate>
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="iClarkesCost" DataType="System.Decimal" FilterControlAltText="Filter iClarkesCost column" HeaderText="ClarkesCost" SortExpression="iClarkesCost" UniqueName="iClarkesCost" ForceExtractValue="Always">
    <FilterTemplate>
    <telerik:RadTextBox ID="fTxtCost" runat="server" Width="80"></telerik:RadTextBox>
    </FilterTemplate>
    </telerik:GridBoundColumn>
    <telerik:GridCheckBoxColumn AllowFiltering="false" DataField="iPaid" DataType="System.Boolean" FilterControlAltText="Filter iPaid column" HeaderText="Paid" SortExpression="iPaid" UniqueName="iPaid" ForceExtractValue="Always">
    </telerik:GridCheckBoxColumn>
    <telerik:GridBoundColumn DataField="iDescription" FilterControlAltText="Filter iDescription column" HeaderText="iDescription" SortExpression="Description" UniqueName="iDescription" ForceExtractValue="Always">
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="iLocation" FilterControlAltText="Filter iLocation column" HeaderText="iLocation" SortExpression="Location" UniqueName="iLocation" ForceExtractValue="Always">
    </telerik:GridBoundColumn>
    <telerik:GridTemplateColumn DataField="iDriverAware" HeaderText="Driver" UniqueName="iDriverAware" ForceExtractValue="Always" AllowFiltering="true">
    <FilterTemplate>
    <telerik:RadComboBox ID="rcbFDriverAware" runat="server" AutoPostBack="true" ShowToggleImage="false" Width="80" OnSelectedIndexChanged="rcbFDriverAware_SelectedIndexChanged">
    <Items>
    <telerik:RadComboBoxItem Text="Any" />
    <telerik:RadComboBoxItem Text="Aware" />
    <telerik:RadComboBoxItem Text="At Fault" />
    <telerik:RadComboBoxItem Text="Both" />
    </Items>
    </telerik:RadComboBox>
    </FilterTemplate>
    <ItemTemplate>
    <asp:Label ID="lblDriver" runat="server" Text='<%# Eval("iDriverAware").ToString() == "True" ? Eval("iDriverFault").ToString() == "True" ? "Aware, At Fault" : "Aware" : Eval("iDriverFault").ToString() == "True" ? "At Fault" : ""%>'></asp:Label>
    </ItemTemplate>
    </telerik:GridTemplateColumn>
    <telerik:GridBoundColumn DataField="iDriverFault" UniqueName="iDriverFault" Display="false" AllowFiltering="true"></telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="iAJGRef" FilterControlAltText="Filter iAJGRef column" HeaderText="AJGRef" SortExpression="iAJGRef" UniqueName="AJGRef" ForceExtractValue="Always">
    </telerik:GridBoundColumn>
    <telerik:GridTemplateColumn HeaderText="Depot" AllowFiltering="false" ForceExtractValue="Always">
    <ItemTemplate>
    <telerik:RadDropDownList ID="rgddlDepot" runat="server" DataTextField="dCode" DataValueField="dID" Enabled="false" AppendDataBoundItems="true">
    <Items>
    <telerik:DropDownListItem Value="-1" Text="Select One" />
    </Items>
    </telerik:RadDropDownList>
    </ItemTemplate>
    </telerik:GridTemplateColumn>
    <telerik:GridTemplateColumn HeaderText="Driver">
    <ItemTemplate>
    <telerik:RadDropDownList ID="rgddlDriver" runat="server" DataTextField="dName" DataValueField="dID" Enabled="false" AppendDataBoundItems="true">
    <Items>
    <telerik:DropDownListItem Value="-1" Text="Select One" />
    </Items>
    </telerik:RadDropDownList>
    </ItemTemplate>
    </telerik:GridTemplateColumn>
    <telerik:GridTemplateColumn HeaderText="Vehicle">
    <ItemTemplate>
    <telerik:RadDropDownList ID="rgddlCab" runat="server" DataTextField="cReg" DataValueField="cID" Enabled="false" AppendDataBoundItems="true">
    <Items>
    <telerik:DropDownListItem Value="-1" Text="Select One" />
    </Items>
    </telerik:RadDropDownList>
    </ItemTemplate>
    </telerik:GridTemplateColumn>
    <telerik:GridTemplateColumn HeaderText="Trailer">
    <ItemTemplate>
    <telerik:RadDropDownList ID="rgddlTrailer" runat="server" DataTextField="tRef" DataValueField="tID" Enabled="false" AppendDataBoundItems="true">
    <Items>
    <telerik:DropDownListItem Value="-1" Text="Select One" />
    </Items>
    </telerik:RadDropDownList>
    </ItemTemplate>
    </telerik:GridTemplateColumn>
    </Columns>
    <EditFormSettings>
    <EditColumn UniqueName="EditCommandColumn1" FilterControlAltText="Filter EditCommandColumn1 column"></EditColumn>
    </EditFormSettings>
    </telerik:GridTableView>
    </DetailTables>
    <Columns>
    <telerik:GridBoundColumn DataField="dID" DataType="System.Int32" Display="False" FilterControlAltText="Filter dID column" HeaderText="dID" ReadOnly="True" SortExpression="dID" UniqueName="dID">
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="dCode" AllowFiltering="false" FilterControlAltText="Filter dCode column" HeaderText="Code" SortExpression="dCode" UniqueName="dCode">
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="dName" AllowFiltering="false" FilterControlAltText="Filter dName column" HeaderText="Name" SortExpression="dName" UniqueName="dName">
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="Incidents" AllowFiltering="false" DataType="System.Int32" FilterControlAltText="Filter Incidents column" HeaderText="Incidents" ReadOnly="True" SortExpression="Incidents" UniqueName="Incidents">
    </telerik:GridBoundColumn>
    </Columns>
    </MasterTableView>
    </telerik:RadGrid>

     

    protected void rcbFDriverAware_SelectedIndexChanged( object sender,RadComboBoxSelectedIndexChangedEventArgs e ) {
        string fe;
        switch( e.Text ) {
            case "Any":
                fe = "";
                break;
            case "Aware":
                fe = $"([iDriverAware] = 'true')";
                break;
            case "At Fault":
                fe = $"([iDriverFault] = 'true')";
                break;
            case "Both":
                fe = $"([iDriverAware] = 'true') AND ([iDriverFault] = 'true')";
                break;
            default:
                fe = "";
                break;
        }
        rgdepots.MasterTableView.DetailTables[0].FilterExpression = fe;
        rgdepots.MasterTableView.DetailTables[0].Rebind();
    }
  2. Eyup
    Admin
    Eyup avatar
    3986 posts

    Posted 02 Aug 2017 Link to this post

    Hello Oliver,

    The approach demonstrated in the following live sample should work as expected for detail tables as well:
    http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/filtering/filter-templates/defaultcs.aspx

    Also, you can check the first sample provided in the following post for an actual demonstration:
    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
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top