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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridTemplateColumn change ForegroundColor/BackgroundColor if selected

Thread ID:

Created:

Updated:

Platform:

Replies:

142592 Feb 11,2019 04:02 PM UTC Feb 18,2019 06:05 AM UTC Xamarin.Forms 4
loading
Tags: SfDataGrid
Daniel Koffler
Asked On February 11, 2019 04:02 PM UTC

Hello,
I am using GridTemplateColumns for some custom styling.
How can I react to row selection and change colors accordingly? There seems to be nothing like GridTemplateColumns.SELECTED.
Thank you
Daniel

Subburaj Pandian Veluchamy [Syncfusion]
Replied On February 12, 2019 12:57 PM UTC

Hi Daniel, 
 
Thank you for contacting Syncfusion support. 
 
Currently, we are analyzing on query with DataGrid Column template selection in Xamarin.Forms. We will validate and let you the details in one business day (February 13, 2019). We appreciate your patience until then.  
 
Regards,
Subburaj Pandian V  
 


Subburaj Pandian Veluchamy [Syncfusion]
Replied On February 13, 2019 12:32 PM UTC

Hi Daniel, 
  
Thank you for your patience. 
  
We have checked and you can achieve your requirement of “How to react to Template column when the row selection is changed” using dataGrid selection changed event. Please refer the following code example for your reference, 
  
[C#] 
private void DataGrid_SelectionChanged(object sender, Syncfusion.SfDataGrid.XForms.GridSelectionChangedEventArgs e) 
{ 
    if(e.AddedItems.Count != 0) 
    { 
        // TempalteColor is binding property of template view. 
        (e.AddedItems[0] as OrderInfo).TempalteColor = Color.Green; 
    } 
  
    if (e.RemovedItems.Count != 0) 
    { 
        (e.RemovedItems[0] as OrderInfo).TempalteColor = Color.Red; 
    } 
} 
  
[XAML] 
<sfgrid:GridTemplateColumn MappingName="OrderID"> 
                    <sfgrid:GridTemplateColumn.CellTemplate> 
                        <DataTemplate> 
                            <Label Text="{Binding OrderID}" BackgroundColor="{Binding TempalteColor}"/> 
                        </DataTemplate> 
  
                    </sfgrid:GridTemplateColumn.CellTemplate> 
</sfgrid:GridTemplateColumn> 
  
We have also prepared the sample for your reference and attached in following link. 
  
  
We hope that this will helps you, kindly revert us if you have any concern.  
 
Regards,
Subburaj Pandian V 
 
 


Daniel Koffler
Replied On February 17, 2019 12:43 PM UTC

Hello,

thank you for the solution.
I just switched the order of the AddedItems and RemovedItem if statements.
Otherwise clicking on an already selected row does not work as expected.

Kind regards
Daniel 

Subburaj Pandian Veluchamy [Syncfusion]
Replied On February 18, 2019 06:05 AM UTC

 
Hi Daniel, 
 
Thank you for the update. We are happy that you have meet your requirement. 
 
Please let us know, if you need any further assistance.  
 
Regards,
Subburaj Pandian V  
 
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;