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;
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?
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
Comment
OriginX = 4
When you add the new MergedQuestionResponse column, you would set it up like this:
MergedQuestionResponse
SpanX = 4
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.
UPDATE: Mike, you can ignore my question below as I have found the solution. Just add MQR before the other two.
Hi Mike,
I use exactly this solution, but I have a problem. The header of the MergedQuestionResponse column is displayed and the headers of the Question and Response columns are not displayed. I need the exact opposite situation. I need the header of the MergedQuestionResponse not to be displayed and the headers of the other two to be displayed.
What is the best way of approaching this?
Thanks in advance.