We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Programmatically select row when using Cell Merge feature in SfGrid

Hi,

I have 2 query here that require your support.

1) How can i programmatically select entire row when using cell merge feature in sfgrid? I noticed that from this link, it stated that "Row selection is not supported". Is there any workaround for this issue?

2) I have row style and alternating row style for my grid, when using cell merge, how can i style the cell according to the merged cell? As you can see from the attached sample(taking row 3 as example), column 1 to 8 are merge and the background color should be the same (should be both white), and column 9 and 10 are not merge so it is correct to have different color.

Thanks.

Attachment: Untitled_140d9c56.rar

3 Replies

MK Muthukumar Kalyanasundaram Syncfusion Team July 21, 2017 04:06 AM UTC

Hi Bao,

 

Thank you for contacting Syncfusion Support.

 

We have checked your query. Please find the response from below table,

 

 

Query 1:

How can i programmatically select entire row when using cell merge feature in sfgrid? I noticed that fromthis link, it stated that "Row selection is not supported". Is there any workaround for this issue?

 

We regret to inform that it’s not possible for row selection in merge cell feature in SfDataGrid. You can use Cell selection instead of Row.

 

Query 2:

I have row style and alternating row style for my grid, when using cell merge, how can i style the cell according to the merged cell? As you can see from the attached sample(taking row 3 as example), column 1 to 8 are merge and the background color should be the same (should be both white), and column 9 and 10 are not merge so it is correct to have different color.

 

If you want to apply the style for merge cell, then you can use ColumnBase.IsSpannedColumn property to customize the style of GridCell as like below code. In the below attached sample, we have applied the alternate row style and GridCell style for merge cell. Could you please refer to it.

 

Code Snippet:

 

public class SelectorClass : StyleSelector

{

    public override Style SelectStyle(object item, DependencyObject container)

    {

        var data = item as OrderInfo;

        if (data != null && ((container as GridCell).ColumnBase.GridColumn != null))

        {

            if ((container as GridCell).ColumnBase.IsSpannedColumn)

                return App.Current.Resources["redCellStyle"] as Style;               

        }

        return base.SelectStyle(item, container);

    }

}

 

 

Sample: http://www.syncfusion.com/downloads/support/forum/131589/ze/CellMergeDemo-574424378

 

Please let us know if you have any query.

 

Regards,

Muthukumar K



BY BAO YADONG July 24, 2017 10:50 AM UTC

Hi, your solution doesn't seems to work on my issue. i have attached another image for your reference. Thanks.

Looking forward for your assistant.


Attachment: Untitled_273ec25d.rar


MK Muthukumar Kalyanasundaram Syncfusion Team July 25, 2017 06:39 PM UTC

Hi Bao, 

Thanks for the update. 

We have checked your provided snapshot. Based on this, we have prepared sample. In that, we have applied the GridCell style for merged cell because if you apply the alternate rowstyle, the merged cell also alternate style will be applied. To avoid alternate row color for merge cell, you can apply GridCell style. For your reference, we have attached image and snaphot. Could you please refer to it. 

 


Please let us know if you have any query. 

Regards, 
Muthukumar K 


Loader.
Live Chat Icon For mobile
Up arrow icon