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

Programatically create template filter on grid column

4 Answers 274 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nicholas Walker
Top achievements
Rank 1
Nicholas Walker asked on 06 Oct 2009, 10:10 AM
Do you guys have a simple example of how to create a template filter on a grid column using a RadComboBox in the code-behind?  Been looking through the forum and docs and don't see one.

Thanks,
--nick

4 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 06 Oct 2009, 11:27 AM
Hi Nicholas,

For more information about how to achieve the desired functionality, please refer to the following help article:
Implementing filtering for template/custom columns

I hope this helps.

Regards,

Pavlina
the Telerik team

 


Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Shinu
Top achievements
Rank 2
answered on 06 Oct 2009, 11:52 AM
Hello Nick,

You can also check out the following forum link which provides with an example, how to create a filter template with a combobox dynamically:

Thanks
Shinu.
0
Kevin
Top achievements
Rank 1
answered on 04 Apr 2011, 07:17 PM
This example works great !!

I have a tabstrip, each tab strip will contain a grid.  The number of tabs is not known at design time, the data will be retrieved at run time.  Because of this I am creating each grid programatically.  How do I add a filter on the server side that was previously defined on the client side as:

<custom:MyCustomFilteringColumn DataField="Name" HeaderText="Select Flight">

<HeaderStyle width="75px" horizontalalign="Center"/>

<ItemStyle width="75px" horizontalalign="Left"/>

<itemtemplate>

<%# Eval("Name") %>

</itemtemplate>

</custom:MyCustomFilteringColumn>


Any help would be greatly appreciated.
0
Pavlina
Telerik team
answered on 07 Apr 2011, 02:16 PM
Hi Kevin,

Please examine the code snipped below and let me know if it helps to achieve your goal:
C#
protected override void OnInit(EventArgs e) 
    
        base.OnInit(e); 
        BuildGrid(); 
    
    
    private void BuildGrid() 
    
        RadGrid grid = new RadGrid(); 
        grid.ID = "RadGrid1"
        grid.AllowPaging = true
        grid.AllowSorting = true
        grid.NeedDataSource += new GridNeedDataSourceEventHandler(grid_NeedDataSource); 
    
        GridBoundColumn id = new GridBoundColumn(); 
        id.DataField = "ID"
        id.HeaderText = "ID"
        grid.MasterTableView.Columns.Add(id); 
    
        MyCustomFilteringColumn name = new MyCustomFilteringColumn(); 
        name.HeaderText = "Name"
        name.ItemTemplate = new MyItemTemplate("Name"); 
        grid.MasterTableView.Columns.Add(name); 
    
        this.Controls.Add(grid); 
    
    
    void grid_NeedDataSource(object source, GridNeedDataSourceEventArgs e) 
    
        List<object> data = new List<object>(); 
        for (int i = 0; i < 20; i++) 
        
            data.Add(new { ID=i, Text = "Text " + i}); 
        
    
        ((RadGrid)source).DataSource = data; 
    
    
public class MyItemTemplate : ITemplate 
    
}


All the best,
Pavlina
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
Nicholas Walker
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Shinu
Top achievements
Rank 2
Kevin
Top achievements
Rank 1
Share this question
or