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

Merge Rows

6 Answers 213 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Hector Hernandez
Top achievements
Rank 2
Hector Hernandez asked on 17 Jun 2013, 07:00 AM
Hello people.
i will like to know if thers's a way to make rows merge in the grid?

thanks in advance

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 17 Jun 2013, 07:19 AM
Hi,

Here is an example on merge.Hope this is what you are looking for.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server"
    OnNeedDataSource="RadGrid1_NeedDataSource" OnPreRender="RadGrid1_PreRender">
</telerik:RadGrid>

C#:
protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
   {
       DataTable table = new DataTable();
       table.Columns.Add("Column1");
       table.Columns.Add("Column2");
       table.Columns.Add("Column3");
 
       table.Rows.Add(new object[] { "Cell11", "Cell12", "Cell13" });
       table.Rows.Add(new object[] { "Cell21", "Cell22", "Cell23" });
       table.Rows.Add(new object[] { "Cell31", "Test", "Test1" });
       table.Rows.Add(new object[] { "Test", "Cell42", "Cell43" });
       table.Rows.Add(new object[] { "Test", "Cell52", "Cell53" });
 
       RadGrid1.DataSource = table;
   }
   protected void RadGrid1_PreRender(object sender, EventArgs e)
   {
       foreach (GridDataItem dataItem in RadGrid1.MasterTableView.Items)
       {
           if (dataItem["Column2"].Text == dataItem["Column3"].Text)
           {
               dataItem["Column2"].ColumnSpan = 2;
               dataItem["Column3"].Visible = false;
           }
 
           int previousItemIndex = dataItem.ItemIndex - 1;
           if (previousItemIndex >= 0)
           {
               if (dataItem["Column1"].Text == dataItem.OwnerTableView.Items[previousItemIndex]["Column1"].Text)
               {
                   dataItem.OwnerTableView.Items[previousItemIndex]["Column1"].RowSpan = 2;
                   dataItem["Column1"].Visible = false;
               }
           }
       }
   }

Thanks,
Princy
0
Hector Hernandez
Top achievements
Rank 2
answered on 17 Jun 2013, 04:35 PM
Thanks Princy, i just did that and its works fine but the lines of the Grid (GridLines) dont show even i have set the propierti Gridlines="Both" here is my Grid and an image of it

<telerik:RadGrid runat="server" ID="GrdAnalEst" PageSize="20" 
                                AutoGenerateColumns="false" Width="100%" AllowSorting="true" GridLines="Both"
                                AllowPaging="true">
                                <PagerStyle Mode="NextPrevAndNumeric" NextPageText="Siguiente" 
                              PrevPageText="Anterior" Position="Bottom" 
                              PagerTextFormat="Change page: {4} &amp;nbsp;Pagina &lt;strong&gt;{0}&lt;/strong&gt; de &lt;strong&gt;{1}&lt;/strong&gt;, registros &lt;strong&gt;{2}&lt;/strong&gt; a &lt;strong&gt;{3}&lt;/strong&gt; de &lt;strong&gt;{5}&lt;/strong&gt;." 
                              PageSizeLabelText="Regitros" />
                            <MasterTableView DataKeyNames="CODPROPIEDAD,CODSOLICITANTE,CODPLAN,UMANEJO,area,PARCELA,VOLH" NoMasterRecordsText="No Hay Inventario Ingresado" ShowFooter="true" Name="Labeles">
                                <Columns>
                                    <telerik:GridBoundColumn DataField="CODPROPIEDAD" Visible="false" HeaderText="Codigo" HeaderStyle-Width="75px">
                                        <HeaderStyle Width="225px"></HeaderStyle>
                                    </telerik:GridBoundColumn> 
                                    <telerik:GridBoundColumn DataField="CODSOLICITANTE" Visible="false" HeaderText="Codigo" HeaderStyle-Width="75px">
                                        <HeaderStyle Width="225px"></HeaderStyle>
                                    </telerik:GridBoundColumn> 
                                    <telerik:GridBoundColumn DataField="CODPLAN" Visible="false" HeaderText="Codigo" HeaderStyle-Width="75px">
                                        <HeaderStyle Width="225px"></HeaderStyle>
                                    </telerik:GridBoundColumn> 
                                    <telerik:GridBoundColumn DataField="UMANEJO" HeaderText="Umanejo" HeaderStyle-Width="100px"  FooterText="Total (mt³)" FooterStyle-Font-Bold="true" >
                                        <HeaderStyle Width="100px"></HeaderStyle>
                                    </telerik:GridBoundColumn>    
                                   <telerik:GridBoundColumn DataField="area" HeaderText="Area" HeaderStyle-Width="100px"   >
                                        <HeaderStyle Width="100px"></HeaderStyle>
                                    </telerik:GridBoundColumn> 
                                    <telerik:GridBoundColumn DataField="PARCELA" HeaderText="Parcela" HeaderStyle-Width="100px"   >
                                        <HeaderStyle Width="100px"></HeaderStyle>
                                    </telerik:GridBoundColumn> 
                                      <telerik:GridBoundColumn DataField="VOLH" HeaderText="Vol/Ha (mt³)" HeaderStyle-Width="100px" Visible="false"   >
                                        <HeaderStyle Width="100px"></HeaderStyle>
                                    </telerik:GridBoundColumn> 
                                    <telerik:GridTemplateColumn HeaderText="Volumen por h (mt³)"  UniqueName="VOLH" HeaderStyle-Width="100px" >
                                    <ItemTemplate>
                                        <telerik:RadNumericTextBox runat="server" ID="TxtVolGridEsta" Width="90px">
                                            <NumberFormat DecimalDigits="3" />
                                        </telerik:RadNumericTextBox>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn> 
                                </Columns>        
                            </MasterTableView>
                            <FilterMenu EnableTheming="true">
                                <CollapseAnimation Duration="200" Type="OutQuint" />
                            </FilterMenu>
                        </telerik:RadGrid>
0
Accepted
Princy
Top achievements
Rank 1
answered on 18 Jun 2013, 04:36 AM
Hi,
Please set the following CSS Property and check if it helps.

CSS:
<style type="text/css">
div.AddBorders .rgHeader,
div.AddBorders th.rgResizeCol,
div.AddBorders .rgFilterRow td,
div.AddBorders .rgRow td,
div.AddBorders .rgAltRow td,
div.AddBorders .rgEditRow td,
div.AddBorders .rgFooter td
{
    border-style:solid;
    border-color:#aaa;
    border-width:0 0 1px 1px; /*top right bottom left*/
}
 
div.AddBorders .rgHeader:first-child,
div.AddBorders th.rgResizeCol:first-child,
div.AddBorders .rgFilterRow td:first-child,
div.AddBorders .rgRow td:first-child,
div.AddBorders .rgAltRow td:first-child,
div.AddBorders .rgEditRow td:first-child,
div.AddBorders .rgFooter td:first-child
{
    border-left-width:0;
}
 
</style>

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server"  Width="800px" Skin="Forest" CssClass="AddBorders"    ShowGroupPanel="true" . . . . .>
</telerik:RadGrid>

Thanks,
Princy
0
Hector Hernandez
Top achievements
Rank 2
answered on 18 Jun 2013, 05:32 AM
Thanks Princy
it work's perfect

0
Hector Hernandez
Top achievements
Rank 2
answered on 20 Jun 2013, 05:09 AM
Hi Princy
it´s me again sorry.

is there any way to do the same but in GridTemplateColumn?

Thanks..
0
Hector Hernandez
Top achievements
Rank 2
answered on 20 Jun 2013, 05:19 AM
I found the andswer!!!

Greetings
Tags
Grid
Asked by
Hector Hernandez
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 1
Hector Hernandez
Top achievements
Rank 2
Share this question
or