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

ItemTemplate Content disappearing when using RadGrid Grouping

1 Answer 110 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 1
Sean asked on 23 Jan 2009, 04:28 PM
Hi,

I am using a RadGrid programatically.  I have a GridTemplateColumn :

 

      GridTemplateColumn colState = new GridTemplateColumn();  
      colState.ItemTemplate = new StateControl();  
      colState.HeaderText = "State";  
      colState.Visible = false

 


which uses the following ItemTemplate :

 

public class StateControl : ITemplate  
{  
   public void InstantiateIn(System.Web.UI.Control container)  
   {  
      RadComboBox radcomboState = new RadComboBox();  
      radcomboState.Skin = "Outlook";  
      radcomboState.ID = "radcomboState";  
      radcomboState.AllowCustomText = false;  
      radcomboState.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(radcomboState_SelectedIndexChanged);  
      radcomboState.AutoPostBack = true;  
      radcomboState.Visible = true;  
 
      container.Controls.Add(radcomboState);       
   }  

The RadGrid is set up to allow grouping and all works ok.  However, when the group node is collapsed, the contents disappear from the cell which contains the ItemTemplate data.  The contents disappear even from cells that are not in the group which is being collapsed.

As a test, I set up the ItemTemplate in the .ascx file like this : 

 

               <telerik:GridTemplateColumn HeaderText="State" Reorderable="true">  
                  <ItemTemplate> 
                     <telerik:RadComboBox Skin="Outlook" runat="server" ID="radcomboState" AllowCustomText="false" 
                        OnSelectedIndexChanged="radcomboState_SelectedIndexChanged" AutoPostBack="true">  
                     </telerik:RadComboBox> 
                  </ItemTemplate> 
               </telerik:GridTemplateColumn> 

And it worked fine.  The contents remained in the cells when the group was collapsed.
In the example I have used a RadCombo box, but the same occurs when using a simple Literal.
I need to be able to acheive this programmatically, have I missed something or is there a bug here?

Regards,

Sean Duffy

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 26 Jan 2009, 07:37 AM
Hello Sean,

In order to preserved their state, when template columns creating  programmatically, the entire RadGrid should be created programmatically in page's init event. Please refer to the following help article (under Creating template columns programmatically section) for more details.

Greetings,
Rosen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Sean
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or