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

[Solved] Filtering a column with a combobox

1 Answer 125 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Johnnie Walker
Top achievements
Rank 1
Johnnie Walker asked on 22 Jul 2009, 02:42 PM
Hi,

Hopefully a quick, simple problem.

I've got a RadGrid which uses the NeedDataSource event to poplute with data which works perfectly.  I want to filter a column using a RadComboBox. I've followed various examples which show it working if you databind to the grid declaratively, but work out how to convert the example if I'm using the NeedDataSource method.

Thanks in advance for any help!
Johnnie

P.S. Here is my code for the filter so far:

<telerik:GridBoundColumn DataField="ArticleLength" HeaderText="S/M/L" 
                                    SortExpression="ArticleLength" UniqueName="ArticleLength" ItemStyle-HorizontalAlign="Center">
                                    
                                    <FilterTemplate>
                                        <telerik:RadComboBox ID="RC_FilterArticleLength" DataTextField="ArticleLength"
                                            DataValueField="ArticleLength" Height="100px" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("ArticleLength").CurrentFilterValue %>'
                                            runat="server" OnClientSelectedIndexChanged="RC_FilterArticleLengthChanged">
                                            <Items>
                                                <telerik:RadComboBoxItem Text="All" />
                                            </Items>
                                        </telerik:RadComboBox>
                                        <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">

                                            <script type="text/javascript">
                                                function RC_FilterArticleLengthChanged(sender,args) {
                                                    var tableView=$find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                                    tableView.filter("ArticleLength",args.get_item().get_value(),"EqualTo");
                                                }
                                            </script>
                                        </telerik:RadScriptBlock>
                                    </FilterTemplate>
                         </telerik:GridBoundColumn>

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 27 Jul 2009, 07:54 AM
Hello Johnnie,

Here is a demo page you can refer to. No that you only need to fire RadGrid's Filter command and rebind. RadGrid takes care of the rest, no matter whether you use declarative data source or the NeedDataSource event.

Filter Templates

Greetings,
Veli
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.
Tags
Grid
Asked by
Johnnie Walker
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or