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

Expand a row to show a UserControl

3 Answers 160 Views
GridView
This is a migrated thread and some comments may be shown as answers.
j0rge
Top achievements
Rank 1
j0rge asked on 17 Sep 2007, 04:57 PM
Hi,

1. Is it possible to create a button (image button would be nice since the GridViewCommandColumn is just wrong for this, it should be a + and -) per row? I know you do not support Hierarchies but can I "infuse" a button?

2. On that button click I would like to increase the height of the Row to add a user control that will show details, pie charts, etc. This usercontrol should be as wide as the whole row (not only a cell).

I am thinking of hacking into  the source code but now when Q2 is comming up... well it would be better not to have to migrate that code every time a service pack or version of the Telerik controls is released.

Thanks,
/ jorge

3 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 18 Sep 2007, 03:53 PM
Hi j0rge,

Thank you for writing us.

Currently it is not possible to embed such a user control in our grid control. Nevertheless, this is a nice and powerful feature and we will add it tp our high priority to do list. However, since this is a major feature we can't give you a strict deadline. Still, we will work to deliver it in the near future.

Regarding your first question, consult the codeblock below:

// put this code in your form's load method 
this.samplTableTableAdapter.Fill(this.sampleDatabaseDataSet.SamplTable); 
this.radGridView1.Columns.Add(new GridViewDataColumn( "Button" )); 
 
void radGridView1_CellFormatting( object sender, Telerik.WinControls.UI.CellFormattingEventArgs e ) 
    //this example put progress bar into column "Button" 
    if (e.CellElement.ColumnInfo is GridViewDataColumn && ((GridViewDataColumn)e.CellElement.ColumnInfo).DataField == "Button"
    { 
        if (!(e.CellElement.RowElement is GridHeaderRowElement)) //exclude Header element in the data column                      
        { 
            if (e.CellElement.Children.Count > 0)//the progress bar is already added to cell                          
                return
            RadButtonElement button = new RadButtonElement(); 
            button.Text = "+ / -"
            button.Click += new EventHandler( button_Click ); 
            e.CellElement.Children.Add( button ); 
            ApplyThemeToElement(button, "ControlDefault");                     
             
        } 
    } 
 
 private void ApplyThemeToElement(RadItem item, string themeName) 
    DefaultStyleBuilder builder = ThemeResolutionService.GetStyleSheetBuilder(item.ElementTree.Control,  
        item.GetThemeEffectiveType().FullName, string.Empty, themeName) as DefaultStyleBuilder; 
 
    if (builder != null
        item.Style = new XmlStyleSheet(builder.Style).GetStyleSheet(); //clone because control might modify it later 

Thanks again for contacting us. Your feedback is important in letting us know how to develop your products so that they would be most useful to you.

All the best,
Jack
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Kannan Venkateswaran
Top achievements
Rank 1
answered on 11 Jul 2008, 09:10 PM
ignore this posting
0
Kannan Venkateswaran
Top achievements
Rank 1
answered on 11 Jul 2008, 09:13 PM
sorry wrong thread... ignore my earlier post
Tags
GridView
Asked by
j0rge
Top achievements
Rank 1
Answers by
Jack
Telerik team
Kannan Venkateswaran
Top achievements
Rank 1
Share this question
or