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

FilterTemplate - RadComboBox Default Value

1 Answer 150 Views
Filter
This is a migrated thread and some comments may be shown as answers.
Marc
Top achievements
Rank 1
Marc asked on 18 Nov 2014, 09:51 AM
Hi,

I tried to set a default-Filter-Value in my FilterTemplate.
But my Default-Item doesn´t work as well... The filtering still shows "ALL" items

I need to set the default filter-value as "bearbeitung" (translation: in process)

With "<DefaultItem Text="Bearbeitung" Value="Bearbeitung"/>" it shows the correct value at the combobox.
But still shows all items.

If i choose the value "Bearbeitung" manually from the RadComboBox, the filtering works fine.

<telerik:GridBoundColumn AllowFiltering="true" FilterControlWidth="100px" DataField="TicketStatusBezeichnung" HeaderText="Ticket Status" ShowFilterIcon="true"  AutoPostBackOnFilter="true"><br>                    <FilterTemplate>
<
telerik:RadComboBox  ID="RadComboBoxTicketStatus" DataSourceID="SqlDataSource2" DataTextField="TicketStatusBezeichnung"<br>                            DataValueField="TicketStatusBezeichnung" Height="200px" AppendDataBoundItems="true"  SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("TicketStatusBezeichnung").CurrentFilterValue %>'<br>                            runat="server" OnClientSelectedIndexChanged="TitleIndexChanged" Sort="Descending"><br>                            <DefaultItem Text="Bearbeitung" Value="Bearbeitung"/><br>                            <Items><br>                                <telerik:RadComboBoxItem Text="Alle" /><br>                            </Items><br>                        </telerik:RadComboBox><br>                        <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"><br>                            <script type="text/javascript"><br>                                function TitleIndexChanged(sender, args) {<br>                                    var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");<br>                                    tableView.filter("TicketStatusBezeichnung", args.get_item().get_value(), "EqualTo");<br>                                }<br>                            </script><br>                        </telerik:RadScriptBlock><br>                    </FilterTemplate><br>               
</
telerik:GridBoundColumn>

Thanks in advance :)

best,
Marc B

1 Answer, 1 is accepted

Sort by
0
Accepted
Viktor Tachev
Telerik team
answered on 21 Nov 2014, 08:43 AM
Hi Marc,

In order to set a filter that will be applied initially to RadGrid you can use the following approach:

  • Handle the PreRender event of RadGrid
  • Use the handler to set the FilterExpression property
  • Rebind RadGrid

The approach is also illustrated in the article linked below.


Regards,
Viktor Tachev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Marc
Top achievements
Rank 1
commented on 25 Nov 2014, 07:02 AM

Thank you very much :)

It works fine ;)
shakeel
Top achievements
Rank 1
Iron
commented on 15 Aug 2023, 07:28 AM

<telerik:GridBoundColumn DataField="Request_Status" HeaderText="Request Status"
                                            UniqueName="Request_Status" >
                                            <HeaderStyle HorizontalAlign="left" Width="80px" Font-Size="14px" />
                                            <ItemStyle HorizontalAlign="left" Width="80px" />
                                            <FilterTemplate>
                                                <telerik:RadComboBox RenderMode="Lightweight" ID="StatusCombo" Width="130px" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("Request_Status").CurrentFilterValue %>'
                                                    runat="server" OnClientSelectedIndexChanged="StatusComboIndexChanged">
                                                   
                                                    <Items>
                                                        <telerik:RadComboBoxItem Text="ALL" Value="" />
                                                        <telerik:RadComboBoxItem Text="PENDING" Value="PENDING" Selected="true" />
                                                        <telerik:RadComboBoxItem Text="APPROVED" Value="APPROVED" />
                                                        <telerik:RadComboBoxItem Text="REJECTED" Value="REJECTED" />
                                                        <telerik:RadComboBoxItem Text="AMENDED" Value="AMENDED" />
                                                        <telerik:RadComboBoxItem Text="RESUBMITTED" Value="RESUBMITTED" />

                                                    </Items>
                                                </telerik:RadComboBox>
                                                <telerik:RadScriptBlock ID="RadScriptBlock2" runat="server">
                                                    <script type="text/javascript">
                                                        function StatusComboIndexChanged(sender, args) {
                                                            var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                                            tableView.filter("Request_Status", args.get_item().get_value(), "EqualTo");
                                                        }
                                                    </script>
                                                </telerik:RadScriptBlock>
                                            </FilterTemplate>
                                        </telerik:GridBoundColumn>

Currently, i am using the OnNeedDataSource the bind the grid, i required  when grid load than default filter is pending and show the pending records only,
shakeel
Top achievements
Rank 1
Iron
commented on 15 Aug 2023, 07:29 AM

<telerik:GridBoundColumn DataField="Request_Status" HeaderText="Request Status"
                                            UniqueName="Request_Status" >
                                            <HeaderStyle HorizontalAlign="left" Width="80px" Font-Size="14px" />
                                            <ItemStyle HorizontalAlign="left" Width="80px" />
                                            <FilterTemplate>
                                                <telerik:RadComboBox RenderMode="Lightweight" ID="StatusCombo" Width="130px" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("Request_Status").CurrentFilterValue %>'
                                                    runat="server" OnClientSelectedIndexChanged="StatusComboIndexChanged">
                                                   
                                                    <Items>
                                                        <telerik:RadComboBoxItem Text="ALL" Value="" />
                                                        <telerik:RadComboBoxItem Text="PENDING" Value="PENDING" Selected="true" />
                                                        <telerik:RadComboBoxItem Text="APPROVED" Value="APPROVED" />
                                                        <telerik:RadComboBoxItem Text="REJECTED" Value="REJECTED" />
                                                        <telerik:RadComboBoxItem Text="AMENDED" Value="AMENDED" />
                                                        <telerik:RadComboBoxItem Text="RESUBMITTED" Value="RESUBMITTED" />

                                                    </Items>
                                                </telerik:RadComboBox>
                                                <telerik:RadScriptBlock ID="RadScriptBlock2" runat="server">
                                                    <script type="text/javascript">
                                                        function StatusComboIndexChanged(sender, args) {
                                                            var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                                            tableView.filter("Request_Status", args.get_item().get_value(), "EqualTo");
                                                        }
                                                    </script>
                                                </telerik:RadScriptBlock>
                                            </FilterTemplate>
                                        </telerik:GridBoundColumn>

Currently, i am using the OnNeedDataSource the bind the grid, i required  when grid load than default filter is pending and show the pending records only,
Attila Antal
Telerik team
commented on 17 Aug 2023, 03:42 PM

Hi Shakeel,

Please check out the documentation shared by Viktor and follow the instructions. The filtering will be applied properly.

If the results are not what you expect, you will need to verify the database records and or the filter expression you use to filter the Grid.

Tags
Filter
Asked by
Marc
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or