Ожидание Rowspan при вставке строки в метод сразу в 1 строку при следующей вставке строки в следующий раз путем сравнения - PullRequest
0 голосов
/ 24 марта 2020
private readonly List<string> _contentsRowForRowSpan = new List<string>();
public int _RowCount => this._contentsRowForRowSpan.Count;
private string FirstRowData;
private readonly int RowSpan = 1;

// This method will Call again and again for row entries which is added later to form Table. 
public void AppendRowWithRowSpan(params string[] data) // 
{
  if (data == null)
  {
      throw new ArgumentNullException(nameof(data));
  }

  if (data.Length != this._headingCount)
  {
      throw new ArgumentOutOfRangeException();
  }

  StringBuilder sb = new StringBuilder();

  if (_RowCount==0)
  {
      FirstRowData = data.GetValue(0).ToString();
  }

  for (int i = 0; i < data.Length; i++)
  {
      if (FirstRowData.Equals(data.GetValue(0).ToString()))
      {
          // i Need a output like if Column 1 of Row 1 is Equal to Column 1 of Row 2 is Equal then Rowspan in <td> part and remove in second row like.
          sb.AppendLine($" <td>" + data.GetValue(i).ToString() + " </ td > ");
      }
      else
      {
          sb.AppendLine($" <td> " + data.GetValue(i).ToString() + " </ td > ");
      }

  }

this._contentsRowForRowSpan.Add(sb.ToString());

Input Like Calling метод со входом ‍ AppendRowWithRowspan( "Row11","Row12", "Row13", "Row14)‍‍

снова ввод как AppendRowWithRowspan( "Row11","Row12", "Row13", "Row14)‍

снова ввод как AppendRowWithRowspan( "Row17","Row12", "Row13", "Row14)

вывод как

<td rowspan= 2> Row11<td><td>Row12</td><td>Row13</td><td>Row14</td>
<td>Row12</td><td>Row13</td><td>Row14</td> ------Delete Entry to get Row Span if math in Column 1 only
<td> Row17<td><td>Row12</td><td>Row13</td><td>Row14</td>
...