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

Grid filtering with combobox

3 Answers 122 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Blop
Top achievements
Rank 1
Blop asked on 21 Feb 2012, 11:48 AM
Hi. I'm trying to filter my grid with a combobox but I don't succeed (sorry but the documentation really sux!)

Here's what I'm trying to <telerik:RadGrid AutoGenerateColumns="false" ID="RadGrid1" OnNeedDataSource="NeedDataSourceClient">
  <MasterTableView AllowFilteringByColumn="True" AutoGenerateColumns="false"
<telerik:GridTemplateColumn DataField=country_Id" UniqueName="country_Id SortExpression=country_Id AutoPostBackOnFilter="true">
<FilterTemplate>
<telerik:RadComboBox ID="rcbCountries" runat="server"> </telerik:RadComboBox>
<FilterTemplate>
<ItemTemplate><%# global.GetCountry(DataBinder.Eval(Container, "DataItem.country_Id))%>
</ItemTemplate>
</telerik:GridTemplateColumn
</MasterTableView
</telerik:RadGrid>    


 

How can I do that?

My first issue is to fill my combobox, how can I do that with linq? (which is not explain here:http://www.telerik.com/help/aspnet-ajax/combobox-data-binding-data-source.html as it said in the summary)

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 21 Feb 2012, 12:02 PM
Hello,

Take a look at the following demo.
ComboBox / LinqDataSource

Thanks,
Princy.
0
Blop
Top achievements
Rank 1
answered on 21 Feb 2012, 01:14 PM
Thanx it has helped but I'm now stuck otherwhere.
I've the following error message in the console on indexchange: event.layerX and event.layerY are broken and deprecated in WebKit. They will be removed from the engine in the near future. 

Here's what I did

<telerik:GridTemplateColumn DataField="countryID"  AutoPostBackOnFilter="true">
                            <FilterTemplate>
                                <telerik:RadComboBox runat="server" ID="rcbCountries" DataSourceID="dsCountries" DataTextField="name"                                                              OnClientSelectedIndexChanged="IndexChanged" AppendDataBoundItems="true" >
                                              <Items>                                       
                                              </Items>
                                </telerik:RadComboBox>
                                <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
                                <script type="text/javascript">
                                    function IndexChanged(sender, args) {
                                    var tableView = $find("<%# TryCast(Container,GridItem).OwnerTableView.ClientID %>");
                                        tableView.filter("countryID", args.get_item().get_value(), "EqualTo");
                                       }
                                       </script>
                            </telerik:RadScriptBlock>
                            </FilterTemplate>
                            <ItemTemplate>
                                    <%# global.GetCountry(DataBinder.Eval(Container, "DataItem.country_Id))%> 
                            </ItemTemplate>
</telerik:GridTemplateColumn>
<asp:LinqDataSource runat="server" ID="dsStatus" ContextTypeName="DataContext" Select="new (name)" TableName="Countries" >  </asp:LinqDataSource>

Any idea what I did wrong?
0
Antonio Stoilkov
Telerik team
answered on 24 Feb 2012, 09:30 AM
Hello Blop,

Your implementation is working fine. The message you are seeing is warning message and does not affect the written functionality. Note the message could be seen only in WebKit browsers. You could try debugging in Firefox or IE to see that the message will not appear. Additionally, you could go through the help article below for more in depth information on the client-side filter method.

Kind regards,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Blop
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Blop
Top achievements
Rank 1
Antonio Stoilkov
Telerik team
Share this question
or