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

RadGrid in usercontrol with google style filter

12 Answers 130 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David Sánchez
Top achievements
Rank 1
David Sánchez asked on 23 Sep 2008, 12:23 PM
I've tried this example (http://www.telerik.com/support/kb/article/b454K-ghg-b454T-cbb.aspx) but i have the grid inside a usercontrol, and i can't be able to do it work,  by example a problem is the code in Page_load event , in which event i must to write it?
It would be posible a example?
Thank you in advance.

12 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 26 Sep 2008, 10:31 AM
Hello David Sánchez,

Please find attached a sample project which I prepared, following the project provided in the example you mentioned.
I added the RadGrid in a UserControl and it works as expected.
Please test the application on your side and let us know if it works for you.

Kind regards,
Maria Ilieva
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
David Sánchez
Top achievements
Rank 1
answered on 26 Sep 2008, 02:19 PM

Thaks, but my proble is that i use a load dynamic for the webusercontrol, i use this "loaderControl", then, in your example, you use the page_load event to configure the "googleColumns" and only load the customcolumns in the first call of the page :

If

Not IsPostBack Then

ds = GetDataSet(

"SELECT Country, City, Index FROM Customers")

Me.RadGrid1.MasterTableView.Columns.Clear()

For Each dataColumn As DataColumn In ds.Tables(0).Columns

Dim gridColumn As RadGrid.MyCustomFilteringColumn = New RadGrid.MyCustomFilteringColumn

Me.RadGrid1.MasterTableView.Columns.Add(gridColumn)

gridColumn.DataField = dataColumn.ColumnName

gridColumn.HeaderText = dataColumn.ColumnName

Next

End If



but, i need to know how and when i can configure the columns because in my case, i can't do it in the page load event.

loadercontrol.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml">  
<head runat="server">  
    <title>Untitled Page</title> 
</head> 
<body> 
    <form id="form1" runat="server">  
        <asp:ScriptManager ID="ScriptManager1" runat="server" /> 
        <div> 
          
        <table> 
                <tr> 
                    <td> 
                        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" /> 
                    </td> 
                    <td> 
                        <asp:Panel ID="Panel1" runat="server">  
                        </asp:Panel> 
                    </td> 
                </tr> 
              
        </table> 
 
        </div> 
    </form> 
</body> 
</html> 

loadercontrol.aspx.cs:
using System.Web.UI;  
using System.Web.UI.WebControls;  
using System.Web.UI.WebControls.WebParts;  
using System.Web.UI.HtmlControls;  
 
public partial class _Default : System.Web.UI.Page   
{  
    protected void Page_Load(object sender, EventArgs e)  
    {  
        if (LatestLoadedControlName != null)  
        {  
            LoadUserControl(LatestLoadedControlName);  
        }  
 
 
 
 
    }  
    protected void Button1_Click(object sender, EventArgs e)  
    {  
        this.LoadUserControl("WebUserControl.ascx");  
    }  
 
    private string LatestLoadedControlName  
    {  
        get 
        {  
            return (string)ViewState["LatestLoadedControlName"];  
        }  
        set 
        {  
            ViewState["LatestLoadedControlName"] = value;  
        }  
    }  
 
    public void LoadUserControl(string controlName)  
    {  
        if (LatestLoadedControlName != null)  
        {  
            Control previousControl = Panel1.FindControl(LatestLoadedControlName);  
            if (previousControl != null)  
            {  
                this.Panel1.Controls.Remove(previousControl);  
            }  
        }  
        string userControlID = controlName;  
        Control targetControl = Panel1.FindControl(userControlID);  
        if (targetControl == null)  
        {  
            UserControl userControl = (UserControl)this.LoadControl(controlName);  
            //slashes and tildes are forbidden  
            userControl.ID = userControlID.Replace("/""").Replace("~""");  
            //this.phMain.Controls.Clear();  
            this.Panel1.Controls.Add(userControl);  
            LatestLoadedControlName = controlName;  
        }  
    }  

TA.
0
David Sánchez
Top achievements
Rank 1
answered on 26 Sep 2008, 02:19 PM

Thaks, but my proble is that i use a load dynamic for the webusercontrol, i use this "loaderControl", then, in your example, you use the page_load event to configure the "googleColumns" and only load the customcolumns in the first call of the page :

If

Not IsPostBack Then

ds = GetDataSet(

"SELECT Country, City, Index FROM Customers")

Me.RadGrid1.MasterTableView.Columns.Clear()

For Each dataColumn As DataColumn In ds.Tables(0).Columns

Dim gridColumn As RadGrid.MyCustomFilteringColumn = New RadGrid.MyCustomFilteringColumn

Me.RadGrid1.MasterTableView.Columns.Add(gridColumn)

gridColumn.DataField = dataColumn.ColumnName

gridColumn.HeaderText = dataColumn.ColumnName

Next

End If



but, i need to know how and when i can configure the columns because in my case, i can't do it in the page load event.

loadercontrol.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml">  
<head runat="server">  
    <title>Untitled Page</title> 
</head> 
<body> 
    <form id="form1" runat="server">  
        <asp:ScriptManager ID="ScriptManager1" runat="server" /> 
        <div> 
          
        <table> 
                <tr> 
                    <td> 
                        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" /> 
                    </td> 
                    <td> 
                        <asp:Panel ID="Panel1" runat="server">  
                        </asp:Panel> 
                    </td> 
                </tr> 
              
        </table> 
 
        </div> 
    </form> 
</body> 
</html> 

loadercontrol.aspx.cs:
using System.Web.UI;  
using System.Web.UI.WebControls;  
using System.Web.UI.WebControls.WebParts;  
using System.Web.UI.HtmlControls;  
 
public partial class _Default : System.Web.UI.Page   
{  
    protected void Page_Load(object sender, EventArgs e)  
    {  
        if (LatestLoadedControlName != null)  
        {  
            LoadUserControl(LatestLoadedControlName);  
        }  
 
 
 
 
    }  
    protected void Button1_Click(object sender, EventArgs e)  
    {  
        this.LoadUserControl("WebUserControl.ascx");  
    }  
 
    private string LatestLoadedControlName  
    {  
        get 
        {  
            return (string)ViewState["LatestLoadedControlName"];  
        }  
        set 
        {  
            ViewState["LatestLoadedControlName"] = value;  
        }  
    }  
 
    public void LoadUserControl(string controlName)  
    {  
        if (LatestLoadedControlName != null)  
        {  
            Control previousControl = Panel1.FindControl(LatestLoadedControlName);  
            if (previousControl != null)  
            {  
                this.Panel1.Controls.Remove(previousControl);  
            }  
        }  
        string userControlID = controlName;  
        Control targetControl = Panel1.FindControl(userControlID);  
        if (targetControl == null)  
        {  
            UserControl userControl = (UserControl)this.LoadControl(controlName);  
            //slashes and tildes are forbidden  
            userControl.ID = userControlID.Replace("/""").Replace("~""");  
            //this.phMain.Controls.Clear();  
            this.Panel1.Controls.Add(userControl);  
            LatestLoadedControlName = controlName;  
        }  
    }  

TA.
0
Maria Ilieva
Telerik team
answered on 29 Sep 2008, 06:25 AM
Hi David Sánchez,

Please review the following help topics which will clarify the requirements needed to acheive your scenario:

RadGrid ProgrammaticCreation
Loading user control with Telerik RadGrid at runtime





All the best,
Maria Ilieva
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Nirav Nayak
Top achievements
Rank 1
answered on 03 Jul 2010, 07:49 AM
Hi ,

I am using Telerik Version - 2010.1.309.20 RadGrid control.

Google style filter was working fine with AJAX Extensions 1.0 and we were using asp:scritmanager for AJAX.

we upgraded our application with AJAXControlToolkit-3.5.40412.0 version and changed master page with toolkitscriptmanager.


<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %> 
<ajaxToolkit:ToolkitScriptManager ID="masterPageScriptManager" runat="server" AsyncPostBackTimeout="1200" 
 
 
      EnableScriptGlobalization="true">  
 
 
</ajaxToolkit:ToolkitScriptManager> 

Now We are getting filtering issue. It doesn't populate the filter dropdownlist and keep on displaying Loading.... message.
When I debug the code it was executing correctly without any exception. It was getting data and RadCombobox object and successfuly assigning the datasource and executing the Databind() function.

So can you just help us in finding the cause of this issue. As we have not change anything in code.

Do i miss any configuration part.



 

0
Maria Ilieva
Telerik team
answered on 05 Jul 2010, 03:57 PM
Hello,

I tried to replicate the filtering issue with the ToolkitScriptManager but to no avail. Please find attached a sample application which works as expected on my side. Test it locally and let me know if it works for you.


Greetings,
Maria Ilieva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Nirav Nayak
Top achievements
Rank 1
answered on 06 Jul 2010, 06:59 AM
Hi ,

Thanks for the quick reply.

Well i was having issue with google style filtering dropdown list.

Now it got resolved.

We added HTTPModule in our web application which alter the response based on some condition. We haven't handle this response for FIlter postback request and it was clearing the resoponse data.

 

 





0
Maria Ilieva
Telerik team
answered on 06 Jul 2010, 02:09 PM
Hi Nirav,

I'm glad that you have managed to fix the problem.
Do not hesitate to contact Telerik Support if further assistance is needed.

Greetings,
Maria Ilieva
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Nirav Nayak
Top achievements
Rank 1
answered on 06 Jul 2010, 02:34 PM
Hi ,

I want to populate filter dropdownlist from Grid Datasource.
I have used onNeedDatasouce event for assigning datasource to RadGrid.

 public class MyGridBoundColumn : GridBoundColumn  
    {   
....  
....  
....  
private void list_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)  
        {  
           ObjectDataSource source = (ObjectDataSource).Owner.OwnerGrid.DataSourceObject;  
                source.FilterExpression = filter;  
            dv = (DataView)source.Select();  
            dv.Sort = this.UniqueName + " ASC";  
            DataTable dt = dv.ToTable(true, new string[] { this.UniqueName });  
            (o as RadComboBox).DataSource = dt;  
            (o as RadComboBox).DataTextField = this.DataField;  
            (o as RadComboBox).DataValueField = this.DataField;  
            (o as RadComboBox).DataBind();  
 
        }  

Now issue is that needdatasource event doesn't fire when I click on filter textbox. So I am getting null grid datasource on list_ItemsRequested event and thats why dropdown comes empty.

So any solution to fill this filter dropdownlist from RadGrid Datasource.

can we call NeedDatasource event explicitly.
0
Maria Ilieva
Telerik team
answered on 08 Jul 2010, 08:48 AM
Hello,

Please refer to the following help topic which elaborates on how to operate with the FilterExpression of RadGrid.

Sincerely yours,
Maria Ilieva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Nirav Nayak
Top achievements
Rank 1
answered on 08 Jul 2010, 02:21 PM
Hi,

I read the help topic but still didn't get the solution out of it.

If you want i can send a sample project.


0
Maria Ilieva
Telerik team
answered on 09 Jul 2010, 11:40 AM
Hello Nirav,

It will be best to open regular support ticket and send us sample runnable application. We will test it locally and advise you further.

All the best,
Maria Ilieva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
David Sánchez
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
David Sánchez
Top achievements
Rank 1
Nirav Nayak
Top achievements
Rank 1
Share this question
or