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

Pivot data

1 Answer 106 Views
Grid
This is a migrated thread and some comments may be shown as answers.
HL
Top achievements
Rank 1
HL asked on 08 Mar 2009, 05:36 PM

Hi,

I have a pivot data which is exactly in the radgrid example of displaying pivot data. (Grid/Examples/Programming/Pivot/DefaultCS.aspx)
1. How can I change the font of row 3, column 2 and 3 in the pivot data?
2. How can I insert a button in row 4 of the pivot data?

Can anyone suggest me a way to do so in vb?

Thank you for your help.

 

 

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 09 Mar 2009, 07:37 AM
Hi,

You can try out the following code to change the font of columns in a particular row of the pivot grid:
cs:
 protected void RadGrid1_PreRender(object sender, EventArgs e)  
    {  
        RadGrid1.MasterTableView.Items[3].Cells[3].Font.Bold = true;  
        RadGrid1.MasterTableView.Items[3].Cells[4].Font.Bold = true;  
    }  

You can also try out the following code to insert a button in a row the pivot data. Here, I check for the text of the cell in the ItemDataBound event so as to add the button to that particular cell.
cs:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)  
    {         
        if (e.Item is GridDataItem)  
        {            
                (e.Item as GridDataItem)[(RadGrid1.MasterTableView.AutoGeneratedColumns[1] as GridBoundColumn).UniqueName].Controls.Clear();  
                Button btn = new Button();  
                (e.Item as GridDataItem)[(RadGrid1.MasterTableView.AutoGeneratedColumns[1] as GridBoundColumn).UniqueName].Controls.Add(btn);  
                btn.Text = "CustomButton";  
                btn.ID = "Button1";  
                btn.Click += new EventHandler(btn_Click);  
         }  
    }  
 
void btn_Click(object sender, EventArgs e) 
    { 
      RadGrid1.Rebind(); 
    } 
 
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
          if (e.Item is GridDataItem) 
            { 
                if ((e.Item as GridDataItem)[(RadGrid1.MasterTableView.AutoGeneratedColumns[1] as GridBoundColumn).UniqueName].Text == "Maria Anders"
                { 
                    (e.Item as GridDataItem)[(RadGrid1.MasterTableView.AutoGeneratedColumns[1] as GridBoundColumn).UniqueName].Controls.Clear(); 
                    Button btn = new Button(); 
                    (e.Item as GridDataItem)[(RadGrid1.MasterTableView.AutoGeneratedColumns[1] as GridBoundColumn).UniqueName].Controls.Add(btn); 
                    btn.Text = "CustomButton"
                    btn.ID = "Button1"
                    
                } 
            } 
    } 

-Princy.
Tags
Grid
Asked by
HL
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or