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

tables inside grid column

3 Answers 46 Views
Grid
This is a migrated thread and some comments may be shown as answers.
MBEN
Top achievements
Rank 1
Veteran
MBEN asked on 11 Feb 2013, 07:46 PM

Hi I have a scenario where I am creating table inside 2 seperate grid columns. I want the tables inside both the columns to be the same size.

For ex table 1 can have 4 rows while table 2 can have 6 rows. I match up the rows in table1 and table2 and if there is no matching row I add an empty cell to that row.

I want the rows to have the same height so the rows look aligned with the data... data in table1 to data in table2 or empty row in table1 to data in table 2. or if the data in table2 wraps to two lines then the corresponding row in table1 to have the same height.
Currently, they don't align well as the rows with empty space don't take up any height.

I've tried adding row height but that doesn't help.Please suggest

below is my code:

      GridDataItem item = e.Item as GridDataItem;
       int accountID = Int32.Parse(item.GetDataKeyValue("AccountID").ToString());
       DataRow[] dr = PayoutElection.GetPayouts_ByAccount_ListByParticipant(Int32.Parse(Profile.ParticipantID), accountID, PayoutTypeFilter);
 
       Table tblPayoutType = new Table();
       Table tblPayoutDesc = new Table();
       Table tblEffectiveDate = new Table();
       foreach (DataRow row in dr)
       {
           TableRow trPayoutType = new TableRow();
           trPayoutType.Attributes.Add("class", "mergedItems");
           TableRow trPayoutDesc = new TableRow();
           trPayoutDesc.Attributes.Add("class", "mergedItems");
           TableRow trEffectiveDate = new TableRow();
           trEffectiveDate.Attributes.Add("class", "mergedItems");
 
           TableCell cellPayoutType = new TableCell();
           cellPayoutType.Text = row["PayoutType"].ToString();
 
           TableCell cellPayoutDesc = new TableCell();
           cellPayoutDesc.Text = row["PayoutDescription"].ToString();
 
           TableCell cellEffectiveDate = new TableCell();
           DateTime effDate = (DateTime)row["EffectiveDate"];
           DateTime currentDate = DateTime.Parse(Profile.CurrentDate);
           cellEffectiveDate.Text = effDate.ToString(Utility.MBFormatDate);
 
           trPayoutType.Cells.Add(cellPayoutType);
           tblPayoutDesc.Rows.Add(trPayoutDesc);
           trPayoutDesc.Cells.Add(cellPayoutDesc);
           tblPayoutType.Rows.Add(trPayoutType);
           trEffectiveDate.Cells.Add(cellEffectiveDate);
           tblEffectiveDate.Rows.Add(trEffectiveDate);
 
           if (effDate > currentDate)
           {
               if (cellPayoutType.Text == _currentPayoutType)
               {
                   cellPayoutType.Text = "";
               }
           }
     }
item["PayoutType"].Controls.Add(tblPayoutType);
item["PayoutDescription"].Controls.Add(tblPayoutDesc);

3 Answers, 1 is accepted

Sort by
0
Antonio Stoilkov
Telerik team
answered on 14 Feb 2013, 10:57 AM
Hi,

In order to achieve your scenario you could place a   as text in the cell in order to force it to take its height.
if (effDate > currentDate)
{
    if (cellPayoutType.Text == _currentPayoutType)
    {
        cellPayoutType.Text = " ";
    }
}


All the best,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
MBEN
Top achievements
Rank 1
Veteran
answered on 14 Feb 2013, 04:43 PM
That does not help.
The problem occurs when the text in rows of table 2 wraps in second line. I want to force the row in table 1 to have the same height as row in table2 if the text wraps.

Please help.
0
Antonio Stoilkov
Telerik team
answered on 19 Feb 2013, 07:37 AM
Hello,

In your scenario the tables could be aligned only on the client using JavaScript code on page load and manually set the rows height. The client-side approach is required because there is no way to determine on the server if a cell will span on two lines. Note that this is developer responsibility. Additionally, if you have any additional questions related to RadControls please do not hesitate to contact us again.

Regards,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
MBEN
Top achievements
Rank 1
Veteran
Answers by
Antonio Stoilkov
Telerik team
MBEN
Top achievements
Rank 1
Veteran
Share this question
or