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

Header

7 Answers 147 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dip
Top achievements
Rank 1
Dip asked on 09 Jul 2008, 07:58 PM
Is there a way where we can "Insert a row before the Header" in the Event ITEMCREATED...


thanks,
DIP

7 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 10 Jul 2008, 06:25 AM
Hi Dip,

I dont think it is possible to insert a row above the Grid Header. But you can use a CommandItemTemplate to fit for a row.

ASPX:
 <MasterTableView    CommandItemDisplay="top"  Width="900px" TableLayout="Fixed" EditMode="InPlace" DataSourceID="SqlDataSource2" > 
                   <CommandItemTemplate> 
                     <table> 
                       <tr> 
                        <td> 
                            <asp:Label ID="Label2" runat="server" Text="Label2"></asp:Label> 
                        </td> 
                        <td> 
                            <asp:Label ID="Label3" runat="server" Text="Label3"></asp:Label> 
                        </td> 
                        <td> 
                            <asp:Label ID="Label4" runat="server" Text="Label4"></asp:Label> 
                        </td> 
                       </tr> 
                     </table> 
                   </CommandItemTemplate> 

Thanks
Shinu.
0
Dip
Top achievements
Rank 1
answered on 10 Jul 2008, 02:19 PM
This doesn;t work for me as I have to come up with code from the server side..I know how to do it in Asp Control, but failing in telerik Control..

Thanks,
DIP
0
Dip
Top achievements
Rank 1
answered on 10 Jul 2008, 08:33 PM

protected

void Rad_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)

{

if (e.Item is GridHeaderItem)

{

RadGrid g = (RadGrid)sender;

GridTableView h = new GridTableView(g);

GridHeaderItem u = new GridHeaderItem(h,0,0);

GridTableHeaderCell cell = new GridTableHeaderCell();

cell.Text =

"CustomText";

cell.ColumnSpan = 3;

cell.BackColor = System.Drawing.

Color.Gold;

u.Cells.Add(cell);

g.Controls.AddAt(0, u);

Label1.Text =

"GOGGO";

}

}

I was able to inset a column above the Header,but can't get Colspan to work it properly...
If any one can I will be really greatfull...

thanks,
DIP

0
Yavor
Telerik team
answered on 11 Jul 2008, 07:11 AM
Hello Dip,

As posted initially, you can use the CommandItem template to achieve this functionality.
Other than this, adding the item(s) programatically is not the recommended approach. In what ways does the approach of nesting the item in the CommandItem template, come short?

Best wishes,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Princy
Top achievements
Rank 2
answered on 11 Jul 2008, 10:43 AM
Hi Dip,

You can refer the following help document link to get more details about the CommandItemTempplate in RadGrid.
Command item template

Thanks
Princy.
0
Dip
Top achievements
Rank 1
answered on 11 Jul 2008, 12:46 PM
Hi,

Thanks for the reply,
Well let me explain my problem,
   
        Name                Contact
 First        Last       Email      Phone
***         ***         ***          ***
###         ###         ###          ###

one thing the CommandTemplate Comes short is that when I resize my "Last" column then it comes to fall under Contact.Now CommandItemTemplate stays static with fix length. It would be good if column were not resizable, but well my first requirement to  resizable and second to put Group Header. So that is where CommandItemTemplate fall short. I hope I statement my problem well..

thanks for any help,

Thanks,
DIP   
0
Shinu
Top achievements
Rank 2
answered on 14 Jul 2008, 09:35 AM
Hi Dip,

Try using GridTemlateColumns to achieve the desired scenario.

ASPX:
 <telerik:GridTemplateColumn UniqueName="TempCol1" > 
                       <HeaderTemplate> 
                         <TABLE id="Table1" cellSpacing="1"  cellPadding="1" width="300" border="1"
                           <TR> 
                            <TD colspan="2" align="center"><b>Name</b></TD
                           </TR> 
                            <TR> 
                              <TD width="50%"><b>First</b></TD
                              <TD width="50%"><b>Last</b></TD
                           </TR> 
                         </TABLE> 
                  </HeaderTemplate> 
                  <ItemTemplate> 
                          <TABLE id="Table2" cellSpacing="1" cellPadding="1" width="300" border="1"
                           <TR> 
                            <TD width="50%"><%# DataBinder.Eval(Container.DataItem, "First")%></TD
                            <TD width="50%"><%# DataBinder.Eval(Container.DataItem, "Last")%></TD
                           </TR> 
                       </TABLE> 
                   </ItemTemplate> 
                        </telerik:GridTemplateColumn> 
                         
                        <telerik:GridTemplateColumn UniqueName="TempCol2" > 
                      <HeaderTemplate> 
                         <TABLE id="Table1" cellSpacing="1"  cellPadding="1" width="300" border="1"
                           <TR> 
                            <TD colspan="2" align="center"><b>Contact</b></TD
                           </TR> 
                            <TR> 
                              <TD width="50%"><b>Email</b></TD
                              <TD width="50%"><b>Phone</b></TD
                           </TR> 
                         </TABLE> 
                  </HeaderTemplate> 
                  <ItemTemplate> 
                          <TABLE id="Table2" cellSpacing="1" cellPadding="1" width="300" border="1"
                           <TR> 
                            <TD width="50%"><%# DataBinder.Eval(Container.DataItem, "Email")%></TD
                            <TD width="50%"><%# DataBinder.Eval(Container.DataItem, "Phone")%></TD
                           </TR> 
                       </TABLE> 
                   </ItemTemplate> 
        </telerik:GridTemplateColumn> 


Thanks
Shinu.
Tags
Grid
Asked by
Dip
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Dip
Top achievements
Rank 1
Yavor
Telerik team
Princy
Top achievements
Rank 2
Share this question
or