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

RadGrid created from code-behind not triggering filter postbacks

3 Answers 119 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Amod
Top achievements
Rank 1
Amod asked on 15 Jan 2016, 05:30 AM

Hi,

I have a radgrid built completely from code-behind as a server-control. I am trying to add column filters to some of its columns. When I set the properties required for filtering (AllowFilteringByColumn on the grid) I see the filters on the columns. I then create the columns in code-behind - set the filter properties on them - and add it to the grid's column collection. When I type text in the filter column and press Enter the page/grid doesn't postback. Nothing happens. What am I missing in the below code?

The constructor that initializes the control
public RadGridOpportunity()
{
    this.ID = "grdOpportunity";
    this.MasterTableView.AutoGenerateColumns = false;
    this.MasterTableView.DataKeyNames = new string[] { "ID" };
    this.MasterTableView.Columns.Add(ColStatus());
    this.MasterTableView.HierarchyLoadMode = GridChildLoadMode.ServerBind;
    this.MasterTableView.NoRecordsTemplate = new TemplateNoRecords();
    this.ItemCommand += RadGridOpportunity_ItemCommand;           
    this.ItemCreated += RadGridOpportunity_ItemCreated;
    this.MasterTableView.NestedViewTemplate = new TemplateNestedView();
    this.NeedDataSource += RadGridOpportunity_NeedDataSource;
 
    //filtering
    this.AllowFilteringByColumn = true;
    this.MasterTableView.AllowFilteringByColumn = true;
}

 The column that is built and added to the columns collection-

protected GridColumn ColStatus()
{
    GridBoundColumn col = new GridBoundColumn();
    col.HeaderText = "Status";
    col.DataField = "Status";
    col.CurrentFilterFunction = GridKnownFunction.Contains;
    col.ShowFilterIcon = false;
    col.AutoPostBackOnFilter = true;
    col.DataType = Type.GetType("System.String");
    return col;
}

 

3 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 19 Jan 2016, 01:08 PM
Hi Amod,

What event are you using to create the RadGrid control?

I tested the behavior with the RadGrid created in Page_Init and the filtering is working as expected on my end. Check out the attached sample for illustration.



Regards,
Viktor Tachev
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Amod
Top achievements
Rank 1
answered on 19 Jan 2016, 05:17 PM

Hi Viktor,

Thanks for your reply. Your sample works. I have the below hierarchy on the page.

++Page

++++RadTabStrip

++++++RadMultipage.RadPagView

++++++++PlaceHolder

++++++++++Dynamic RadGrid.

I am injecting the grid in the placeholder at runtime. If I remove the above hierarchy and inject the grid directly on the page it works. Otherwise it doesn't. The grid is initialized in the RadTabStrip's init event. Am I missing something here?

0
Viktor Tachev
Telerik team
answered on 22 Jan 2016, 10:59 AM
Hello Amod,

Try to use the Init event of the RadMultiPage control and see how the behavior changes. I tested the behavior and it is working as expected on my end. Check out the attached sample as reference.


Regards,
Viktor Tachev
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Amod
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Amod
Top achievements
Rank 1
Share this question
or