Merge Rows

7 posts, 1 answers
  1. Hector Hernandez
    Hector Hernandez avatar
    45 posts
    Member since:
    Oct 2009

    Posted 17 Jun 2013 Link to this post

    Hello people.
    i will like to know if thers's a way to make rows merge in the grid?

    thanks in advance
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 17 Jun 2013 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Hector Hernandez
    Hector Hernandez avatar
    45 posts
    Member since:
    Oct 2009

    Posted 17 Jun 2013 Link to this post

    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>
  5. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 17 Jun 2013 Link to this post

    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
  6. Hector Hernandez
    Hector Hernandez avatar
    45 posts
    Member since:
    Oct 2009

    Posted 18 Jun 2013 Link to this post

    Thanks Princy
    it work's perfect

  7. Hector Hernandez
    Hector Hernandez avatar
    45 posts
    Member since:
    Oct 2009

    Posted 20 Jun 2013 Link to this post

    Hi Princy
    it´s me again sorry.

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

    Thanks..
  8. Hector Hernandez
    Hector Hernandez avatar
    45 posts
    Member since:
    Oct 2009

    Posted 20 Jun 2013 Link to this post

    I found the andswer!!!

    Greetings
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017