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

check box in the header of the radgrid hierarchical

4 Answers 119 Views
Grid
This is a migrated thread and some comments may be shown as answers.
nsrikanth 2009
Top achievements
Rank 1
nsrikanth 2009 asked on 14 May 2010, 12:39 PM
hi

this is srikanth,i am new to telerik Controls

my requirement is

1) place the  check box as  a header of the expand and collapse buttons column.
2) selecting the parent or child  row, changing the parent back ground color as a normal selection of row and changing the child row Table background .


thanks and Regards
Srikanth

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 14 May 2010, 02:10 PM
Hello Srikanth,

Check out the following code snippet for placing checkbox in the header of the expandcollapse column.

C#:
 protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
  { 
    if (e.Item is GridHeaderItem && e.Item.OwnerTableView.Name == "Master") 
        { 
            GridHeaderItem hitem = (GridHeaderItem)e.Item; 
            CheckBox chk = new CheckBox(); 
            hitem["ExpandColumn"].Controls.Add(chk); 
        } 
   }  

I am not quite sure about the second requirement. Could you elaborate about the requirement?

Regards,
Princy.
0
nsrikanth 2009
Top achievements
Rank 1
answered on 18 May 2010, 11:13 AM
hi Princy

thanks for your reply,

first requirement is full filled by using this  Code

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
  { 
    if (e.Item is GridHeaderItem
        { 
            GridHeaderItem hitem = (GridHeaderItem)e.Item; 
            CheckBox chk = new CheckBox(); 
            hitem["ExpandColumn"].Controls.Add(chk); 
        } 
   }  


which is given by you but i modified the if condition


my second Requirement is

if user clicks on the parent or child record .we have to select the parent record and change background  color of the child Record same like shown in the attached image.

thanks and Regards
Srikanth.Narala



0
Princy
Top achievements
Rank 2
answered on 18 May 2010, 02:31 PM
Hello Srikanth,

 Check out the following code and see whether it suits your need.

C#:

 protected
 void RadGrid1_SelectedIndexChanged(object sender, EventArgs e) 
    { 
        GridDataItem selecteItem = (GridDataItem)RadGrid1.SelectedItems[0]; 
        if (selecteItem.OwnerTableView.Name == "DetailTableView1"
        { 
            ((selecteItem.OwnerTableView as GridTableView).ParentItem as GridDataItem).Selected = true
             foreach(GridDataItem altItem in (selecteItem.OwnerTableView as GridTableView).Items) 
            { 
                altItem.BackColor = System.Drawing.Color.Blue; 
            } 
 
        } 
        if (selecteItem.OwnerTableView.Name == "Master"
        {           
            foreach(GridDataItem altItem in selecteItem.ChildItem.NestedTableViews[0].Items) 
            { 
                altItem.BackColor = System.Drawing.Color.Blue; 
            } 
         } 
    } 

Regards,
Princy.
0
nsrikanth 2009
Top achievements
Rank 1
answered on 18 May 2010, 03:56 PM
hi Princy

thanks for ur reply,

but i am unable test that code beacuse it not firing the event

i am sending my code as  attachment


i think the solution which is given it is server side but i need the functionality at client side

thanks and regards
srikanth.n

Tags
Grid
Asked by
nsrikanth 2009
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
nsrikanth 2009
Top achievements
Rank 1
Share this question
or