Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
180
Merge Row Cells
posted

I have an issue where I want to merge cells in a Row not a Column.  I'll explain my situation;

I have a grid of questions and responses.  Some questions do not have a response, so I want to merge the question and reponse cells together so that the question text spans across both cells.  There is a 3rd column in the grid with comments in as shown below;

Question Response Comment
Question1 Response1 Comment1
Question2 Response2 Comment2
Question3LongText Comment3
Question4 Response4 Comment4
Question5 Response5 Comment4

I want the cell highlighted in yellow to merge or span to 2nd cell. I still want this to behave as a row because there is data in the Comment column to write back to the database.

Please can someone tell me if this is possible?

Parents
  • 469350
    Verified Answer
    Offline posted

    The grid has no functionality built-in for merging cells in the same row. So there's no easy way to do this.

    One way you could do it is to use RowLayouts and have 2 cells occupying the same space and then only show one or the other.

    In other words, you would hav 4 columns in your grid: Question, Response, Comment, and MergedQuestionResponse.

    In the RowLayout, but default, the columns would be set up like this:

    Question

    OriginX = 0

    OriginY = 0

    SpanX = 2

    SpanY = 2

    Response

    OriginX = 2

    OriginY = 0

    SpanX = 2

    SpanY = 2

    Comment

    OriginX = 4

    OriginY = 0

    SpanX = 2

    SpanY = 2

     

    When you add the new MergedQuestionResponse column, you would set it up like this:

    MergedQuestionResponse

    OriginX = 0

    OriginY = 0

    SpanX = 4

    SpanY = 2

    With a SpanX of 4 and the same Origin as the Question column, this column would exist in the same place that the existing two columns (Question and Response) exist.

    Then, in the InitializeRow event of the grid, you set the hidden property on three cells in the row. If you want a split that shows two columns, then you make sure hidden is false on the Question and Response cells and that hidden is true on the MergedQuestionAndResponse cell. If you want to show merged data, then you reverse the hidden settings.

    You will also need to handle copying the value from the two cells into the one cell and vice versa.

Reply Children
No Data