This is a migrated thread and some comments may be shown as answers.
How to set default value to filter the rows in RadGrid?
1 Answer 5 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Uli asked on 27 Aug 2020, 07:49 AM

I have a combobox as filter in RadGrid. The combobox has "Alle"(all), "Nein"(no), "Ja"(yes) . The "Alle" was default. The page shows all 75 rows after loaded.

I want to have "Ja" as default and to show the 73 rows with "Ja". So I added OnLoad="cboFilterFormActive_Load" in the RadComboBox and a C# method cboFilterFormActive_Load(...).

The aspx code now is like:

<telerik:RadGrid ID="radGridForms" runat="server"
                 DataSourceID="SqlDataSource_Grid" AllowSorting="true" AllowPaging="true" PageSize="10" AllowFilteringByColumn="true"
    <MasterTableView AutoGenerateColumns="false" AllowMultiColumnSorting="true">
        <CommandItemSettings ShowExportToExcelButton="true" ShowAddNewRecordButton="false" ShowRefreshButton="false" />
            <telerik:GridTemplateColumn DataField="FormKey" UniqueName="FormKey">
            <telerik:GridTemplateColumn DataField="visible" HeaderText="aktiv" UniqueName="FormActive">
                    <telerik:RadComboBox ID="cboFilterFormActive" runat="server" RenderMode="Lightweight"
                                         Skin="Bootstrap" Width="100%" ToolTip="Filter Formular aktiv"
                                         DataSourceID="SqlDataSource_FilterFormActive" DataTextField="visible" DataValueField="visible"
                                         SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("FormActive").CurrentFilterValue %>'   
                    <telerik:RadScriptBlock ID="RadScriptBlockFilterVisible" runat="server">
                        <script type="text/javascript">
                            function visibleComboIndexChanged(sender, args) {
                                var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                tableView.filter("FormActive", args.get_item().get_value(), "EqualTo");
                    <asp:Label ID="lblFormVisible" runat="server" Text='<%# translateBool(Eval("visible")) %>'></asp:Label>
        <PagerStyle Position="TopAndBottom" AlwaysVisible="true" />
    <SortingSettings SortedBackColor="#EDEDED" EnableSkinSortStyles="false"></SortingSettings>
    <FilterMenu Skin="Bootstrap" EnableEmbeddedSkins="false" RenderMode="Lightweight"></FilterMenu>


a new mothod in aspx.cs:

        protected void cboFilterFormActive_Load(object sender, EventArgs e)
            var combo = (RadComboBox)sender;
            RadComboBoxItem itm = combo.FindItemByText("Ja");
            if (itm !=null)
                itm.Selected = true;


The "Ja" is now default in the Combobox. But it doesn't filter. All the 75 values are shown after loading page. How can I make it filter "Ja" out?

1 Answer, 1 is accepted

Sort by
Top achievements
Rank 1
answered on 28 Aug 2020, 07:35 AM

My solution is 

in aspx:

<telerik:RadGrid ...>

                        <ClientEvents OnGridCreated="TableCreated"/>


<telerik:RadScriptBlock  ID="RadCodck1" runat="server">
                    <script type="text/javascript">                       
                        function TableCreated() {
                            var fl = sessionStorage.getItem("pageloaded");                            
                            if (fl === null) {
                                var tableView = $find("<%= radGridForms.ClientID %>").get_masterTableView();
                                tableView.filter("FormActive", 1, "EqualTo"); // "Ja" has index 1
                                sessionStorage.setItem("pageloaded", true);

in js:

when page is closing 

function (e)  {



Asked by
Top achievements
Rank 1
Answers by
Top achievements
Rank 1
Share this question