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

Column and Row merging

6 Answers 481 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Leśmian
Top achievements
Rank 2
Leśmian asked on 30 Oct 2015, 03:34 PM
Hi,
I have a question about how to implement scenario presented on the picture table.png? There are 2 separate problems. First and more important is how to implement cell spanning in RadGridView? I had some luck with Custom row layout combined with Style selector and DataTriggers. Then for some rows I managed to change layout do display only cell with TextBlock like in the Row 3 on the picture. Is this the right approach? Well, it works then I lose all the standard styling and behavior (like highlight and so on). Is there any possibility to maintain standard row look and span cells?

The second problems is with headers. As you can see the table has some multilevel headers. I was able to create some sort of substitution of the presented header with Column Groups, but it's not the same, eg. Header 6 should span 2. The main struggle is that content cells are connected directly to Headers in second row, 3rd row of headers is only for labeling and is not connected to the table content? 

6 Answers, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 02 Nov 2015, 11:23 AM
Hello, Lukas,

You can see examples of cells spanning multiple rows and/or columns in our Merged Cells article in the RadGridView documentation.

Information on how to group headers can be found in our Column Groups article and more specifically - in the Nested ColumnGroups, an example of which can be found on Figure 2.

There is currently, however, no straightforward way to span headers on multiple rows.
One suggestion would be to just leave the above row empty and apply a style to the header.

Regards,
Dilyan Traykov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Leśmian
Top achievements
Rank 2
answered on 02 Nov 2015, 07:02 PM

Yes, I saw the examples or rows/column spanning using Merged Cells just as I wrote before. The problem is that to use it I need to have the same value for each cell. That isn't what I want, because my DataSource contain list different objects, lets say Apples and Oranges, which are derived from one generic class. So now I want that for every Apple there will be row with 5 columns and for Oranges there will be only one column (spanning all table columns). Apples and Oranges have different properties so I cannot use Merged Cells. I achieved that by defining custom row layout and applying it by implicit row style. It works fine, but custom row lost all the RadGridViewRow style. So is there any simple why to style it to look like normal RadGridView row other than manually defining all the styles for it?

 

About spanning headers, if I leave the above row empty how to style the beneath row to cover it? Should I create custom style with height property exceeding header height?

 

The last question. Is it possible to add to RadGridView a "static" first row which will serve only as a label row (something like a second header row, but with different spanning)? I should be frozen row, so always first, non editable etc? Because as you can see on the attached picture my "real" columns are in second header row and third header row has different column spanning.

0
Dilyan Traykov
Telerik team
answered on 04 Nov 2015, 03:35 PM
Hello Lukas,

I'm afraid there's no straightforward way to merge the cells in the desired way as IsCellMergingEnabled is applied to the column itself and thus cannot be different for every separate row. As you have probably guessed, the way to achieve it is by playing around with the row layout.

I would recommend removing the header borders and vertically aligning the text to the top to achieve the desired spanning header effect.

For the "static" first row, you can just set its IsEnabled property to false and see if that suits your needs.

Please let me know if this information helps and feel free to follow up with any further questions.

Regards,
Dilyan Traykov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Leśmian
Top achievements
Rank 2
answered on 06 Nov 2015, 08:20 AM

Thx Dilyan for your help. Now I have better understanding of gridviewcontrol capabilities. 

 I have another question. I'd like to add background to the cell depending on the value of property bound to that cell. I done that by using CellStyleSelector, but now cells don't get highlighted when user hover or selects a row? How can I set a background to the cell but remain other styles untouched?

0
Dilyan Traykov
Telerik team
answered on 10 Nov 2015, 04:14 PM
Hello again Lukas,

You can take a look at this possible solution and just set the background value to #AARRGGBB where AA is the alpha channel where 00 is fully transparent and FF is fully visible. For example, you can try with #66FF0000 for a red transparent background.

Another approach has been suggested here. It's a bit more complicated and involves modifying the GridViewRow/GridViewCell template structure.

Let me know if any of these solutions solves your issue.

Regards,
Dilyan Traykov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Leśmian
Top achievements
Rank 2
answered on 12 Nov 2015, 10:12 AM
We went with the semitransparent background solution and it works well as long as the background of the cell is not too dark ;p I think it's good enough for our case. Thx for your help Dilyan.
Tags
GridView
Asked by
Leśmian
Top achievements
Rank 2
Answers by
Dilyan Traykov
Telerik team
Leśmian
Top achievements
Rank 2
Share this question
or