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

FilterTemplate filter value remains "All"

14 Answers 761 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lenny_shp
Top achievements
Rank 2
Lenny_shp asked on 08 Apr 2009, 03:55 PM
http://www.telerik.com/help/aspnet-ajax/radgrid-filter-template.html
The first time run it's correctly displaying "All", after I select a different dropdown item, the grid filters correctly, but the FilterDropDown still indicates "All".    How do I make it display the value that was selected?

Update:  It works now after I change it to use the client side version of example:

                    OnClientSelectedIndexChanged="TitleIndexChanged" SelectedValue='<%# TryCast(Container,GridItem).OwnerTableView.GetColumn("Application").CurrentFilterValue %>'


The Server side still has the issue:

                    <FilterTemplate> 
                        <telerik:RadComboBox runat="server" ID="FilterCombo" DataSourceID="srcApplication" AppendDataBoundItems="true" 
                        DataValueField="Application" DataTextField="Application" AutoPostBack="true"
                        SelectedValue='<%# TryCast(Container,GridItem).OwnerTableView.GetColumn("Application").CurrentFilterValue %>'
                        OnSelectedIndexChanged="FilterCombo_SelectedIndexChanged"
                            <Items> 
                                <telerik:RadComboBoxItem Text="All" /> 
                            </Items>                         
                        </telerik:RadComboBox>            
                    </FilterTemplate>                     
                </telerik:GridBoundColumn>   

    Protected Sub FilterCombo_SelectedIndexChanged(ByVal o As ObjectByVal e As RadComboBoxSelectedIndexChangedEventArgs) 
        Dim filterExpression As String 
        filterExpression = "([Application] = '" + e.Value + "')" 
        RadGrid1.MasterTableView.FilterExpression = filterExpression 
        RadGrid1.MasterTableView.Rebind() 
    End Sub 

14 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 10 Apr 2009, 02:05 PM
Hello Leonid,

To achieve the desired functionality I suggest that you use the approach in the following live demo.
Try to follow this scenario and let me know how it goes and if any other questions arise.

Kind regards,
Pavlina
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Elfman
Top achievements
Rank 1
answered on 17 Apr 2009, 05:00 PM
It does work with the javascript embedded client side, but only if filtering is on by default.
 I also tried to move the s"elect change"  function server side and the event never fired.

By default - I show my grids w/o the Filters, then a user can check a box to show them.

Client side when the filters are shown is says my "onchange" function is not found.
Server side - it never fires an autopostback.

If I dynamically turn on filtering - I get   Microsoft JScript runtime error: 'StatusIndexChanged' is undefined

 

OnClientSelectedIndexChanged="StatusIndexChanged"

 

 



Why doesn't 

 

OnSelectedIndexChanged="StatusIndexChanged"  call the server function - or how can I set the drop down list to be set for autopostback ?

 

In my codebehind - I Tried to set the autopostback:

 

Dim StatusDDL As RadComboBox = CType(filteringItem("Status").Controls(0), RadComboBox)

 

StatusDDL.Width = Unit.Pixel(100)

StatusDDL.AutoPostBack =

True

 

StatusDDL.DropDownWidth = Unit.Pixel(100)



But i get an error - Unable to cast object of type 'System.Web.UI.LiteralControl' to type 'Telerik.Web.UI.RadComboBox'.

 

 






0
Pavlina
Telerik team
answered on 21 Apr 2009, 12:44 PM
Hi Rob,

Unfortunately we can not determine the exact cause for the issue you encountered without a working application which demonstrate it. At this point I will ask you to open a formal support ticket and send us a simple working project with reproduced this erroneous behavior. We will examine it in detail and will get back to you with our findings.

Best wishes,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Gunjan
Top achievements
Rank 1
answered on 28 Apr 2009, 08:10 PM
Was there a solution for this bug? I have the same issue, but would like to use the code behind since I need this for multiple GridDropDownColumns. The filter works, but the index resets to the first entry. I've tested the code by manually setting e.value to "" while debugging.

.ascx Code:
            <telerik:GridDropDownColumn DataField="PRIORITY_ID" HeaderText="Job Priority"
                SortExpression="PRIORITY_ID" UniqueName="PRIORITY_ID"
                DataSourceID="sqlDSPriority" ListTextField="PRIORITY_NAME" ListValueField="PRIORITY_ID">
                <FilterTemplate>
                    <telerik:RadComboBox runat="server" ID="FilterPriorityID" AutoPostBack="true"
                        DataSourceID="sqlDSPriority" DataTextField="PRIORITY_NAME" DataValueField="PRIORITY_ID"
                        OnSelectedIndexChanged="FilterCombo_SelectedIndexChanged" AppendDataBoundItems="true">
                        <Items>
                            <telerik:RadComboBoxItem />
                        </Items>
                    </telerik:RadComboBox>
                </FilterTemplate>
            </telerik:GridDropDownColumn>

.ascx.cs Code:
        // Event handler for filtering the GridDropDownColumn
        // Note - The DataValueField has to equal the unique name of the GridDropDownColumn in order for
        //        this event handler to work.
        protected void FilterCombo_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            // Check if we are clearing the filter expression
            if (string.IsNullOrEmpty(e.Value))
            {
                // Clear the filter expression
                RadGrid1.MasterTableView.FilterExpression = string.Empty;
            }
            else
            {
                // Set the filter expression
                RadGrid1.MasterTableView.FilterExpression = "([" + (o as RadComboBox).DataValueField + "] = '" + e.Value + "')";
            }

            // Rebind the data
            RadGrid1.MasterTableView.Rebind();
        }
0
Pavlina
Telerik team
answered on 30 Apr 2009, 11:51 AM
Hello Gunjan,

To achieve the desired functionality, I suggest that you save the selected item OnSelectedIndexChange and retrieve the data OnPreRender event.
Give a try on the following code snippet and let me know how it goes.

ASPX:
 <telerik:GridDropDownColumn DataField="ContinentName" HeaderText="Continent" UniqueName="ContinentName" 
                        ListValueField="ContinentName" ListTextField="ContinentName" DataSourceID="SqlDataSource1">  
                        <FilterTemplate> 
                            <telerik:RadComboBox ID="rcbContinents"   
                                AppendDataBoundItems="true" 
                                runat="server"   
                                AutoPostBack="true" 
                                DataSourceID="SqlDataSource1"   
                                DataTextField="ContinentName"   
                                DataValueField="ContinentName" 
                                Skin="Vista"   
                                OnSelectedIndexChanged="rcbContinents_SelectedIndexChanged" 
                                OnPreRender="rcbContinents_PreRender">  
                                <Items> 
                                    <telerik:RadComboBoxItem Text="All" Value="" /> 
                                </Items> 
                            </telerik:RadComboBox>         
                        </FilterTemplate> 
                    </telerik:GridDropDownColumn> 

C#
protected void rcbContinents_SelectedIndexChanged(object o, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)  
    {  
        RadComboBox continentsCombo = o as RadComboBox;  
          
        //save the combo selected value  
        ViewState["continentsComboValue"] = continentsCombo.SelectedValue;          
          
        //filter the grid  
        RadGrid1.MasterTableView.FilterExpression = "ContinentName LIKE '%" + continentsCombo.SelectedValue + "%'";  
        RadGrid1.Rebind();          
    }  
 
    protected void rcbContinents_PreRender(object sender, EventArgs e)  
    {  
        //persist the combo selected value  
        if (ViewState["continentsComboValue"] != null)  
        {  
            RadComboBox continentsCombo = sender as RadComboBox;  
            continentsCombo.SelectedValue = ViewState["continentsComboValue"].ToString();  
        }  
    } 

I hope this helps.

All the best,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Gunjan
Top achievements
Rank 1
answered on 30 Apr 2009, 01:43 PM
Thank you for the solution. I've added the PreRender function and it's now saving the selected index. My filter value is an integer, so the filter expression in your code will not work for me:

Original:  
        RadGrid1.MasterTableView.FilterExpression = "ContinentName LIKE '%" + continentsCombo.SelectedValue + "%'";  
 
New:  
        RadGrid1.MasterTableView.FilterExpression = "ContinentName = " + continentsCombo.SelectedValue;  
 
 

I had to modify my code to allow for multiple column filters, which is working, but only when a drop down filter is selected last. I enabled the auto-filtering for the grid view, which allows multiple columns to be filtered at once. When filtering on a non-drop down filter column, the filter expression seems to be removing the drop down list filter from the expression. Is this a bug or am I doing something wrong in my code?

ASCX:
            <telerik:GridDropDownColumn DataField="PRIORITY_ID" HeaderText="Job Priority" 
                SortExpression="PRIORITY_ID" UniqueName="PRIORITY_ID" 
                DataSourceID="sqlDSPriority" ListTextField="PRIORITY_NAME" ListValueField="PRIORITY_ID">  
                <FilterTemplate> 
                    <telerik:RadComboBox runat="server" ID="FilterPriorityID" AutoPostBack="true" 
                        DataSourceID="sqlDSPriority" DataTextField="PRIORITY_NAME" DataValueField="PRIORITY_ID" 
                        OnPreRender="FilterCombo_OnPreRender" OnSelectedIndexChanged="FilterCombo_SelectedIndexChanged" 
                        AppendDataBoundItems="true">  
                        <Items> 
                            <telerik:RadComboBoxItem /> 
                        </Items> 
                    </telerik:RadComboBox> 
                </FilterTemplate> 
            </telerik:GridDropDownColumn> 
 


C#:
        // ************************************************************************************* //  
        //  Event handler for setting the filtered list index to the selected value.             //  
        // ************************************************************************************* //  
        protected void FilterCombo_OnPreRender(object sender, EventArgs e)  
        {  
            RadComboBox rcbFilter = sender as RadComboBox;  
 
            // Persist the selected value  
            if (ViewState[rcbFilter.ID] != null)  
            {  
                // Set the index to the selected value  
                rcbFilter.SelectedValue = ViewState[rcbFilter.ID].ToString();  
            }  
        }  
 
        // ************************************************************************************* //  
        //  Event handler for filtering the GridDropDownColumns.                                 //  
        //  Note - The DataValueField has to equal the unique name of the GridDropDownColumn     //  
        //         in order for this event handler to work.                                      //  
        // ************************************************************************************* //  
        protected void FilterCombo_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)  
        {  
            RadComboBox rcbFilter = o as RadComboBox;  
            string rcbFilterExpr = "([" + rcbFilter.DataValueField + "] = " + rcbFilter.SelectedValue + ")";  
 
            // Save the selected value  
            ViewState[rcbFilter.ID] = rcbFilter.SelectedValue;  
 
            // Check if the column is already being filtered  
            if (RadGrid1.MasterTableView.FilterExpression.Contains(rcbFilter.DataValueField))  
            {  
                // Save the current filter expression & clear it in the master table view  
                string separator = " AND ";  
                string[] filterExpression =  
                    RadGrid1.MasterTableView.FilterExpression.Split(new string[] { separator }, StringSplitOptions.None);  
                RadGrid1.MasterTableView.FilterExpression = string.Empty;  
 
                // Parse each filter expression  
                foreach (string colFilter in filterExpression)  
                {  
                    // Check if this is the column filter we are replacing  
                    if (colFilter.Contains(rcbFilter.DataValueField))  
                    {  
                        // Check if we are not clearing the column filter  
                        if (!string.IsNullOrEmpty(e.Value))  
                        {  
                            // Add the new column filter  
                            RadGrid1.MasterTableView.FilterExpression += rcbFilterExpr + separator;  
                        }  
                    }  
                    // Else, save the existing column filter  
                    else 
                    {  
                        RadGrid1.MasterTableView.FilterExpression += colFilter + separator;  
                    }  
                }  
 
                // Remove the last separator from the filter expression  
                RadGrid1.MasterTableView.FilterExpression =  
                    RadGrid1.MasterTableView.FilterExpression.Substring(0, RadGrid1.MasterTableView.FilterExpression.Length - separator.Length);  
            }  
            // Else, add the new column filter  
            else 
            {  
                // Add the filter  
                if (string.IsNullOrEmpty(RadGrid1.MasterTableView.FilterExpression))  
                {  
                    RadGrid1.MasterTableView.FilterExpression = rcbFilterExpr;  
                }  
                else 
                {  
                    RadGrid1.MasterTableView.FilterExpression += " AND " + rcbFilterExpr;  
                }  
            }  
 
            // Filter the data  
            RadGrid1.MasterTableView.Rebind();  
        }  
 
0
Pavlina
Telerik team
answered on 04 May 2009, 01:46 PM
Hi Gunjan,

If you want to customize filtering using your own custom statements, clear the FilterExpression string (to prevent the default filtering) and bind the grid to a filtered data set.

For more information, please refer to the following articles:
Basic filtering
Custom option for filtering (FilterListOptions -> VaryByDataTypeAllowCustom)
Operating with the FilterExpression of Telerik RadGrid manually

Greetings,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Gunjan
Top achievements
Rank 1
answered on 04 May 2009, 08:01 PM
Thanks for the help. I was looking into other methods of filtering, and found that setting the filter expression of the column to work with my custom drop-down filter lists. The problem is rebinding the filtered data in the radgrid.

Steps:
1) Select an item from the drop-down filter list
2) Radgrid refreshes and data does not look filtered
3) On another column (GridDataBoundColumn) enter a filter expression
4) Radgrid refreshes filtering the data w/ both expressions.

Debugging my the PreRender handler (previous code to load drop down value from viewstate) the filter expression of the masterview contains the correct filter expression of the drop-down filter list. Shouldn't the Rebind() method work, or is there another method I need to call in order to filter the data?

Thanks,

Gunjan

C# code:
        protected void FilterCombo_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) 
        { 
            RadComboBox rcbFilter = o as RadComboBox; 
            string rcbFilterExpr = "([" + rcbFilter.DataValueField + "] = " + rcbFilter.SelectedValue + ")"
 
            // Save the selected value 
            ViewState[rcbFilter.ID] = rcbFilter.SelectedValue; 
 
            // Add the filter expression 
            foreach (GridColumn gc in this.RadGrid1.MasterTableView.Columns) 
            { 
                if (gc.UniqueName.Equals(rcbFilter.DataValueField)) 
                { 
                    // Check if we are clearing the filter 
                    if (string.IsNullOrEmpty(rcbFilter.SelectedValue)) 
                    { 
                        gc.CurrentFilterFunction = GridKnownFunction.NoFilter; 
                        gc.CurrentFilterValue = string.Empty; 
                    } 
                    else 
                    { 
                        gc.CurrentFilterFunction = GridKnownFunction.EqualTo; 
                        gc.CurrentFilterValue = rcbFilter.SelectedValue; 
                    } 
 
                    // Apply the column filter 
                    this.RadGrid1.Rebind(); 
 
                    // Column found, break from the loop 
                    break
                } 
            } 
 
0
Gunjan
Top achievements
Rank 1
answered on 04 May 2009, 10:46 PM
I figured out how to do it. I'm using the FireCommandEvent() to filter the custom drop-down filter. Please let me know if this is a suitable method. Also, I'm comparing the "DataValueField" with the "UniqueName", but was wondering if there is a better method.

Thanks for the help,

Gunjan

ASCX:
<telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticInserts="True" 
    AllowAutomaticUpdates="True" AllowFilteringByColumn="True" AllowSorting="True" 
    DataSourceID="sqlDSJobs" GridLines="None" 
    onitemdatabound="RadGrid1_ItemDataBound" 
    onitemcreated="RadGrid1_ItemCreated" 
    onitemupdated="RadGrid1_ItemUpdated" 
    oniteminserted="RadGrid1_ItemInserted"
<HeaderContextMenu> 
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
</HeaderContextMenu> 
 
<MasterTableView allowpaging="True" autogeneratecolumns="False" datakeynames="JOB_ID"  
        datasourceid="sqlDSJobs" commanditemdisplay="Top"
    <RowIndicatorColumn> 
        <HeaderStyle Width="20px" /> 
    </RowIndicatorColumn> 
 
    <ExpandCollapseColumn> 
        <HeaderStyle Width="20px" /> 
    </ExpandCollapseColumn> 
        <Columns> 
            <telerik:GridEditCommandColumn /> 
            <telerik:GridBoundColumn DataField="JOB_ID" HeaderText="Job ID" ReadOnly="true" 
                SortExpression="JOB_ID" UniqueName="JOB_ID" /> 
            <telerik:GridDropDownColumn DataField="PRIORITY_ID" HeaderText="Job Priority" AutoPostBackOnFilter="true" 
                SortExpression="PRIORITY_ID" UniqueName="PRIORITY_ID" 
                DataSourceID="sqlDSPriority" ListTextField="PRIORITY_NAME" ListValueField="PRIORITY_ID"
                <FilterTemplate> 
                    <telerik:RadComboBox runat="server" ID="FilterPriorityID" AutoPostBack="true" 
                        DataSourceID="sqlDSPriority" DataTextField="PRIORITY_NAME" DataValueField="PRIORITY_ID" 
                        OnPreRender="FilterCombo_OnPreRender" OnSelectedIndexChanged="FilterCombo_SelectedIndexChanged" 
                        AppendDataBoundItems="true"
                        <Items> 
                            <telerik:RadComboBoxItem /> 
                        </Items> 
                    </telerik:RadComboBox> 
                </FilterTemplate> 
            </telerik:GridDropDownColumn> 
            <!-- Additional Columns --> 
        </Columns> 
 
<EditFormSettings> 
<EditColumn UniqueName="EditCommandColumn1"></EditColumn> 
</EditFormSettings> 
 
    <PagerStyle Mode="NextPrevAndNumeric" /> 
</MasterTableView> 
 
<FilterMenu> 
    <CollapseAnimation Type="OutQuint" Duration="200" /> 
</FilterMenu> 
</telerik:RadGrid> 

C#:
        // ************************************************************************************* // 
        //  Event handler for setting the filtered list index to the selected value.             // 
        // ************************************************************************************* // 
        protected void FilterCombo_OnPreRender(object sender, EventArgs e) 
        { 
            RadComboBox rcbFilter = sender as RadComboBox; 
 
            // Persist the selected value 
            if (ViewState[rcbFilter.ID] != null
            { 
                // Set the index to the selected value 
                rcbFilter.SelectedValue = ViewState[rcbFilter.ID].ToString(); 
            } 
        } 
 
        // ************************************************************************************* // 
        //  Event handler for filtering the GridDropDownColumns.                                 // 
        //  Note - The DataValueField has to equal the unique name of the GridDropDownColumn     // 
        //         in order for this event handler to work.                                      // 
        // ************************************************************************************* // 
        protected void FilterCombo_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) 
        { 
            RadComboBox rcbFilter = o as RadComboBox; 
 
            // Save the selected value in the view state 
            ViewState[rcbFilter.ID] = rcbFilter.SelectedValue; 
 
            // Parse each column in the radgrid 
            foreach (GridColumn gc in this.RadGrid1.MasterTableView.Columns) 
            { 
                // See if this is the column which triggered the event 
                if(gc.UniqueName.Equals(rcbFilter.DataValueField)) 
                { 
                    // See if we are clearing the filter 
                    if (string.IsNullOrEmpty(rcbFilter.SelectedValue)) 
                    { 
                        gc.CurrentFilterFunction = GridKnownFunction.NoFilter; 
                        gc.CurrentFilterValue = string.Empty; 
                    } 
                    // Else, set the new filter expression 
                    else 
                    { 
                        gc.CurrentFilterFunction = GridKnownFunction.EqualTo; 
                        gc.CurrentFilterValue = rcbFilter.SelectedValue; 
                    } 
                     
                    // Apply the new filter 
                    (rcbFilter.NamingContainer as GridFilteringItem).FireCommandEvent( 
                        "Filter"new Pair(gc.CurrentFilterFunction.ToString(), gc.UniqueName)); 
 
                    // Column found, break from loop 
                    break
                } 
            } 
        } 

0
omair
Top achievements
Rank 1
answered on 18 Jun 2009, 06:06 PM
I am getting an error:

Expression of Type Boolean expected.

When I try to change index on the filter template of RadComboBox on server side.

However, if I use client side script, I get following error:
Selection out of range Parameter name: value.

I need help.
                        <FilterTemplate>   
                            <tlk:RadComboBox ID="TypeList" Height="100px" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("BuildingItemType").CurrentFilterValue %>'   
                                runat="server"   
                                   OnClientSelectedIndexChanged="TypeIndexChanged" > 
                                <Items> 
                                    <tlk:RadComboBoxItem Text="All" /> 
                                </Items> 
                            </tlk:RadComboBox> 
                            <tlk:RadScriptBlock ID="RadScript2" runat="server">  
 
                                <script type="text/javascript">  
                                    function TypeIndexChanged(sender, args) {  
                                        var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");  
                                        tableView.filter("BuildingItemType", args.get_item().get_value(), "Contains");  
                                          
 
                                    }  
 
                                     
                                </script> 
 
                            </tlk:RadScriptBlock> 
                        </FilterTemplate>   
        protected void TypeList_PreRender(object sender, EventArgs e)  
        {  
            //persist the combo selected value     
            if (ViewState["TypeListComboValue"] != null)  
            {  
                RadComboBox typeListCombo = sender as RadComboBox;  
                typeListCombo.SelectedValue = ViewState["TypeListComboValue"].ToString();  
            }  
        }    
        protected void TypeList_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)  
        {  
              
            RadComboBox continentsCombo = sender as RadComboBox;  
 
            //save the combo selected value     
            ViewState["TypeListComboValue"] = continentsCombo.SelectedValue;  
 
            //filter the grid     
            BuildingItemList.MasterTableView.FilterExpression = "BuildingItemTypeDescription LIKE '%" + continentsCombo.SelectedValue + "%'";  
              
            BuildingItemList.MasterTableView.Rebind();   
 
 
        } 

0
Gunjan
Top achievements
Rank 1
answered on 22 Jun 2009, 05:02 PM
I've moved my filtering to client-side with help from telerik support. Make sure you set the column of the FilterIndexChanged() function to the DataValueField of the radcombobox.

Hope this helps,

Gunjan

ASPX:
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"
        function FilterIndexChanged(sender, args, column) { 
            var tableView = $find("<%= RadGrid1.MasterTableView.ClientID %>"); 
            tableView.filter(column, args.get_item().get_value(), "EqualTo"); 
        } 
    </script> 
</telerik:RadCodeBlock> 
 
<telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True" AllowPaging="True" 
    AllowSorting="True" DataSourceID="sqlDSJobs" GridLines="Horizontal" Skin="Vista" 
    AutoGenerateColumns="False" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" 
    AutoGenerateEditColumn="True"
    <MasterTableView DataSourceID="sqlDSJobs" ClientDataKeyNames="JOB_ID" DataKeyNames="JOB_ID" 
        CommandItemDisplay="Top"
        <Columns> 
            <telerik:GridBoundColumn UniqueName="CLIENT_ID" HeaderText="Client" DataField="CLIENT_ID" 
                DataType="System.Int16" SortExpression="CLIENT_ID"
                <FilterTemplate> 
                    <telerik:RadComboBox ID="rcbClientID" AppendDataBoundItems="true" runat="server" MarkFirstMatch="true" 
                        DataSourceID="sqlDSClient" DataTextField="CLIENT_NAME" DataValueField="CLIENT_ID" 
                        OnClientSelectedIndexChanged="function(sender,args){FilterIndexChanged(sender,args,'CLIENT_ID')}" 
                        SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("CLIENT_ID").CurrentFilterValue %>'
                        <Items> 
                            <telerik:RadComboBoxItem Text="All" /> 
                        </Items> 
                    </telerik:RadComboBox> 
                </FilterTemplate> 
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn UniqueName="JOB_ID" SortExpression="JOB_ID" HeaderText="Job ID" 
                DataField="JOB_ID" ReadOnly="True" /> 
            <telerik:GridBoundColumn UniqueName="STATUS_ID" HeaderText="Job Status" DataField="STATUS_ID" 
                DataType="System.Int16" SortExpression="STATUS_ID"
                <FilterTemplate> 
                    <telerik:RadComboBox ID="rcbStatusID" AppendDataBoundItems="true" runat="server" 
                        DataSourceID="sqlDSStatus" DataTextField="STATUS_NAME" DataValueField="STATUS_ID" 
                        OnClientSelectedIndexChanged="function(sender,args){FilterIndexChanged(sender,args,'STATUS_ID')}" 
                        SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("STATUS_ID").CurrentFilterValue %>'
                        <Items> 
                            <telerik:RadComboBoxItem Text="All" /> 
                        </Items> 
                    </telerik:RadComboBox> 
                </FilterTemplate> 
            </telerik:GridBoundColumn> 
            <!-- Additional Columns -->
        </Columns> 
        <PagerStyle Mode="Slider" /> 
    </MasterTableView> 
    <ClientSettings AllowDragToGroup="True"
        <Selecting AllowRowSelect="True" /> 
    </ClientSettings> 
</telerik:RadGrid> 
 

0
Pete
Top achievements
Rank 1
answered on 16 Dec 2010, 03:06 PM
Hello,
Using Telerik version 2010.2.826.35 Rad Grid.
Attempting to use filtering to filter items in a column.   The items in the column can only be Active, Inactive and working.
I'm getting a FilterCombo_SelectedIndexChanged is undefined when I try to do the server side filtering.

ASPX:
<rad:RadGrid id="RadGrid1" 
                                OnItemCreated="RadGrid1_ItemCreated" 
                                OnPreRender="RadGrid1_PreRender" 
                                OnItemCommand="RadGrid1_ItemCommand"                                 
                                 ShowStatusBar="true" runat="server" AllowPaging="False" AllowSorting="True"
                                    AllowMultiRowSelection="True" AutoGenerateColumns="false"  
                                    ClientSettings-Resizing-ResizeGridOnColumnResize="false" 
                                    EnablePostBackOnRowClick="true"
                                    Width="100%"   Height="92%"  Skin="Windows7" AllowFilteringByColumn="true" EnableLinqExpressions="false">
                                    <MasterTableView PageSize="10" Width="100%" TableLayout="Fixed">
                                        <Columns>                        
                                            <rad:GridTemplateColumn UniqueName="CheckBoxTemplateColumn"  
                                            HeaderStyle-Width="10%" 
                                            HeaderStyle-HorizontalAlign="Center" 
                                            AllowFiltering="false">
                                                <HeaderTemplate>
                                                 <asp:CheckBox id="headerChkbox" Text="Select All" OnCheckedChanged="ToggleSelectedState" AutoPostBack="True" runat="server"></asp:CheckBox>
                                                </HeaderTemplate>
                                                <ItemTemplate >
                                                    <asp:CheckBox id="CheckBox1" OnCheckedChanged="ToggleRowSelection" AutoPostBack="True" runat="server" Width="65"></asp:CheckBox>
                                                </ItemTemplate>
                                            </rad:GridTemplateColumn>
                                                                                        <rad:GridBoundColumn 
                                                DataField="NAME" 
                                                DataType="System.String" 
                                                HeaderText="Name"                                                       
                                                UniqueName="NAME" 
                                                HeaderStyle-HorizontalAlign="Center" 
                                                ItemStyle-HorizontalAlign="Center" 
                                                HeaderStyle-Width="40%" 
                                                AllowFiltering="false">
                                                <ItemStyle />
                                            </rad:GridBoundColumn>
                                                                                        <rad:GridBoundColumn 
                                                DataField="STATUS" 
                                                DataType="System.String" 
                                                HeaderText="Status"                                                       
                                                UniqueName="STATUS"                                               
                                                SortExpression="STATUS"                                                
                                                ShowSortIcon="true"  
                                                HeaderStyle-HorizontalAlign="Center" 
                                                ItemStyle-HorizontalAlign="Center" 
                                                HeaderStyle-Width="10%" 
                                                AllowFiltering="true" 
                                                AutoPostBackOnFilter="true" >
                                                <ItemStyle />
                                                <FilterTemplate>
                                                    <rad:RadComboBox ID="RadComboBoxStatus" 
                                                        DataTextField="STATUS" 
                                                        AutoPostBack="true"
                                                        DataValueField="STATUS" Width="70px"                                                          
                                                        runat="server" 
                                                        AppendDataBoundItems="true"
                                                        OnClientSelectedIndexChanged="FilterCombo_SelectedIndexChanged"
                                                        OnPreRender="RadComboBoxStatus_PreRender">
                                                        <Items>                                                             <rad:RadComboBoxItem Text="All"  /> 
                                                            <rad:RadComboBoxItem Text="Active"  /> 
                                                            <rad:RadComboBoxItem Text="Working"  />                                                                     
                                                        </Items>
                                                    </rad:RadComboBox>
                                                                                                   </FilterTemplate>
                                            </rad:GridBoundColumn>
                                                                                    </Columns>
                                    </MasterTableView>
                                    <ClientSettings EnableRowHoverStyle="true" 
                                                    Resizing-AllowColumnResize="true"
                                                    Resizing-AllowRowResize="true"  
                                                    Resizing-EnableRealTimeResize ="false" 
                                                    Resizing-ResizeGridOnColumnResize="false" 
                                                    Resizing-ClipCellContentOnResize ="false">                                                    
                                        <Scrolling AllowScroll ="true" UseStaticHeaders="true" />
                                        <ClientEvents OnColumnResized="OnColumnResized" />                                        
                                    </ClientSettings>
                                    <PagerStyle Mode="Slider"></PagerStyle>
                                </rad:RadGrid>

c#
protected void FilterCombo_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) 
    {
        string filterExpression;
        filterExpression = "([STATUS] = '" + e.Value + "')";
        RadGrid1.MasterTableView.FilterExpression = filterExpression;
        RadGrid1.MasterTableView.Rebind();
    }

But the above event does not fire.  Am I missing something?
Thanks
0
Pete
Top achievements
Rank 1
answered on 16 Dec 2010, 04:10 PM
Please Disregard the last post. I found my error.  I was using OnClientSelectedIndexChanged vs. OnSelectedIndexChanged. 
Thanks, Pete
0
Pavlina
Telerik team
answered on 20 Dec 2010, 02:41 PM
Hi Pete,

I am glad that you could solve the problem on your own.

Best wishes,
Pavlina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Lenny_shp
Top achievements
Rank 2
Answers by
Pavlina
Telerik team
Elfman
Top achievements
Rank 1
Gunjan
Top achievements
Rank 1
omair
Top achievements
Rank 1
Pete
Top achievements
Rank 1
Share this question
or