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

Advanced Data-Binding and Filtering

6 Answers 250 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Darren
Top achievements
Rank 1
Darren asked on 19 May 2011, 07:16 PM
Greetings,

Is there an example of the radGrid with advanced data binding and filtering enabled?

http://demos.telerik.com/aspnet-ajax/grid/examples/programming/needdatasource/defaultvb.aspx

When I enable filtering, I can only filter one column at a time. When I try to filter a second column, the grid forgets the first filter.

Thanks,
Darren

6 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 20 May 2011, 01:51 PM
Hello Darren,

You can refer to the following online example for more information about how to achieve the desired functionality:
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandcombo/defaultvb.aspx?product=grid

Kind regards,
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.

0
Darren
Top achievements
Rank 1
answered on 21 May 2011, 10:06 AM
Pavlina,

Thank you for your response. The google-like grid you recommended suffers from the same problem I am having now. On this demo, I performed the following steps:

1. Type and select "Spain" as the country.
2. Type and select "Madrid" as the city.
3. On the postback, the country combobox goes blank.

Here is what I need to happen:
1. Type and select "Spain" as the country.
2. Type and select "Madrid" as the city.
3. The results come back with any record that has the country as "Spain" AND the city as "Madrid"

This example is trivial but what if there is a Madrid, France? As it is now, I cannot filter for Madrid that is only in Spain. I would instead get back every entry that has Madrid as the city.

The documentation for RadGrid makes is sound like if I just use the advanced databinding method, then filtering works. And it does except for only one column at a time. I would like to filter on multiple columns at the same time. It seems like each postback that I would need to collect and store each filter and make it a part of my SQL statement each time, much more work than the documentation suggests. I am unclear what the best way is to go about this. Do you have any ideas or examples that would simplify this process?

Edit: I would like to have something like the advanced databinding example with multicolumn filtering and not the google-like filtering with multicolumn filtering.

Thank you,
Darren
0
Darren
Top achievements
Rank 1
answered on 25 May 2011, 06:43 PM
Is there any response to this? If you need more information, please let me know.

Thank You
0
Pavlina
Telerik team
answered on 26 May 2011, 12:31 PM
Hello Darren,

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.

Greetings,
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.

0
Darren
Top achievements
Rank 1
answered on 28 May 2011, 11:22 AM
Thank you again for the reply Pavlina.

The example you pointed me to has the select command of the sqldatasource defined in the .aspx file. I need to create the SQL select command dynamically in the code. Depending on what link a user clicks on, the grid will display unique columns upon each request. Following your example:

.aspx
<asp:SqlDataSource ID="SqlDataSource1" runat="server"  />
 
<telerik:RadGrid ID="RadGrid1" runat="server"
    AllowFilteringByColumn="true"
    AllowPaging="true"
    ShowFooter="true"
    PageSize="15"
    PagerStyle-Mode="NextPrevAndNumeric"
    AutoGenerateColumns="true"
    ShowStatusBar="true"
    AllowSorting="true"
    EnableLinqExpressions="false"
    DataSourceID="SqlDataSource1">
    <MasterTableView AllowFilteringByColumn="true" />
</telerik:RadGrid>

.vb
Protected Sub RadGrid1_PreRender(ByVal source As Object, ByVal e As System.EventArgs) Handles RadGrid1.PreRender
        SqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings("mysqlConnectionStringReports").ConnectionString
        SqlDataSource1.ProviderName = "MySql.Data.MySqlClient"
        SqlDataSource1.SelectCommand = getSQLString(RadGrid1.MasterTableView.FilterExpression)
End Sub

However, RadGrid1.MasterTableView.FilterExpression returns an empty string in this example.

My goal was to recreate the SQL statement upon each request and store it as a session variable. Upon each postback, the SQL statement would be altered with each filter. Can you please give me direction how to accomplish this with a dynamic SQL statement?

Thanks,
Darren

0
Pavlina
Telerik team
answered on 02 Jun 2011, 11:03 AM
Hi Darren,

Thank you for contacting us and for your questions.

To achieve your goal, you can handle the Selecting event of the SqlDataSource to which the grid is bound. There if the RadGrid.MasterTableView.FilterExpression is empty string, set to the initial filter expression string.

Check it out and let me know if this works for you.

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
Darren
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Darren
Top achievements
Rank 1
Share this question
or