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
close icon

Conditional formatting update on row item PropertyChanged

I show tasks in the grid. When the status of some task is updated (Task.Status property with changing/changed notifications, etc.) the condition might be satisfied and style should be updated, but it does not work (styles do not change) until I click on the updated row. How to make it work as I expected?

3 Replies

TV Thangapriya V Syncfusion Team April 11, 2013 06:57 AM UTC

Hi Ivan,

If you update any property and want to apply styles for the other cells in the row using conditional format, you need to set RefreshWholeRow API to True. Please refer the following code snippet for this.

Code Snippet[C#]:

public MainWindow()

{

InitializeComponent();

this.dataGrid.Model.RefreshWholeRow = true;

}

And please make sure that INotifyPropertyChanged is used and NotifyPropertyChanges is enabled.

You can refer the following UG link for this.

http://help.syncfusion.com/ug/wpf/grid/default.htm#!Documents/tableoptions.htm

Please let us know if you have any queries.

Regards,

Thangapriya



SS Sankar Sekar replied to Thangapriya V May 9, 2014 04:34 AM UTC

Hi Ivan,

If you update any property and want to apply styles for the other cells in the row using conditional format, you need to set RefreshWholeRow API to True. Please refer the following code snippet for this.

Code Snippet[C#]:

public MainWindow()

{

InitializeComponent();

this.dataGrid.Model.RefreshWholeRow = true;

}

And please make sure that INotifyPropertyChanged is used and NotifyPropertyChanges is enabled.

You can refer the following UG link for this.

http://help.syncfusion.com/ug/wpf/grid/default.htm#!Documents/tableoptions.htm

Please let us know if you have any queries.

Regards,

Thangapriya


XAML
 <syncfusion:GridDataControl Name="ImportDataGrid"
                                        AllowEdit="true"
                                        AllowSelection="Cell"
                                        AutoFocusCurrentItem="True"         
                                        AutoPopulateColumns="False"
                                        AutoPopulateRelations="False"
                                        ColumnSizer="Star"
                                        NotifyPropertyChanges="True"
                                        ShowAddNewRow="False"
                                        Background="DarkGray"        
                                        UpdateMode="PropertyChanged"
                                        VisualStyle="Metro"        
                                        VerticalAlignment="Stretch"
                                        HorizontalAlignment="Stretch"                                                                                  
                                        ScrollViewer.VerticalScrollBarVisibility="Auto"                                                                       
                                        ItemsSource="{Binding PersonCollection, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">




            <!--  Columns  -->
            <syncfusion:GridDataControl.VisibleColumns>
                <!--Selection Column-->
                <syncfusion:GridDataVisibleColumn  HeaderText="Name" IsReadOnly="False" Binding="{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" >
                    <syncfusion:GridDataVisibleColumn.ColumnStyle>
                        <syncfusion:GridDataColumnStyle Background="White" IsThreeState="False" HorizontalAlignment="Center"/>
                    </syncfusion:GridDataVisibleColumn.ColumnStyle>
                    <syncfusion:GridDataVisibleColumn.HeaderStyle>
                        <syncfusion:GridDataColumnStyle HorizontalAlignment="Center" />
                    </syncfusion:GridDataVisibleColumn.HeaderStyle>
                </syncfusion:GridDataVisibleColumn>
                <!--Timer Name Column -->
                <syncfusion:GridDataVisibleColumn Width="Auto" IsReadOnly="True" Binding="{Binding Address, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HeaderText="Address">
                    <syncfusion:GridDataVisibleColumn.ColumnStyle>
                        <syncfusion:GridDataColumnStyle HorizontalAlignment="Center" Background="White"/>
                    </syncfusion:GridDataVisibleColumn.ColumnStyle>
                    <syncfusion:GridDataVisibleColumn.HeaderStyle>
                        <syncfusion:GridDataColumnStyle HorizontalAlignment="Center" />
                    </syncfusion:GridDataVisibleColumn.HeaderStyle>
                </syncfusion:GridDataVisibleColumn>
            </syncfusion:GridDataControl.VisibleColumns>

            <syncfusion:GridDataControl.Relations >
                    <syncfusion:GridDataRelation  RelationalColumn="ProductList"  >
                    <syncfusion:GridDataRelation.TableProperties>
                        <syncfusion:GridDataTableProperties AutoPopulateColumns="False"                                                                                                                                        
                                                            ShowAddNewRow="False"     
                                                            ColumnSizer="Star"
                                                            UpdateMode="PropertyChanged"
                                                            HideEmptyChildGrid="False"   
                                                            AutoPopulateRelations="False"    
                                                            ShowRecordPlusMinus="True"  
                                                            NotifyComplexPropertyChanges="True"
                                                            NotifyPropertyChanges="True"
                                                            DefaultHeaderRowHeight="50">

                                <syncfusion:GridDataTableProperties.ConditionalFormats>

                                    <syncfusion:GridDataConditionalFormat Name="conditionJobFailedRed" ApplyStyleToColumn="ProductDetails">

                                        <syncfusion:GridDataConditionalFormat.Style>
                                            <syncfusion:GridDataStyleInfo Foreground="Red" />
                                        </syncfusion:GridDataConditionalFormat.Style>

                                        <syncfusion:GridDataConditionalFormat.Conditions>
                                            <syncfusion:GridDataCondition ColumnName="ProductDetails" Value="TestModiifcation" />
                                        </syncfusion:GridDataConditionalFormat.Conditions>

                                    </syncfusion:GridDataConditionalFormat>

                                    <syncfusion:GridDataConditionalFormat Name="conditionInprogressYellow" ApplyStyleToColumn="ProductDetails">

                                        <syncfusion:GridDataConditionalFormat.Style>
                                            <syncfusion:GridDataStyleInfo Foreground="Yellow"/>
                                        </syncfusion:GridDataConditionalFormat.Style>

                                        <syncfusion:GridDataConditionalFormat.Conditions>
                                            <syncfusion:GridDataCondition ColumnName="ProductDetails" Value="dfgfdsgfds" />
                                        </syncfusion:GridDataConditionalFormat.Conditions>

                                    </syncfusion:GridDataConditionalFormat>

                                    <syncfusion:GridDataConditionalFormat Name="conditionNoDataSuccessGreen" ApplyStyleToColumn="ProductDetails">

                                        <syncfusion:GridDataConditionalFormat.Style>
                                            <syncfusion:GridDataStyleInfo Foreground="Green"/>
                                        </syncfusion:GridDataConditionalFormat.Style>

                                        <syncfusion:GridDataConditionalFormat.Conditions>
                                            <syncfusion:GridDataCondition ColumnName="ProductDetails" Value="afsfdsfdsfds" />
                                            <syncfusion:GridDataCondition ColumnName="ProductDetails" Value="dfgfdsgfds" />

                                        </syncfusion:GridDataConditionalFormat.Conditions>

                                    </syncfusion:GridDataConditionalFormat>

                                </syncfusion:GridDataTableProperties.ConditionalFormats>
                                <syncfusion:GridDataTableProperties.VisibleColumns>
                                <syncfusion:GridDataVisibleColumn  HeaderText="ProductName" IsReadOnly="True" MappingName="ProductName">
                                    <syncfusion:GridDataVisibleColumn.ColumnStyle>
                                        <syncfusion:GridDataColumnStyle  HorizontalAlignment="Left" />
                                    </syncfusion:GridDataVisibleColumn.ColumnStyle>
                                </syncfusion:GridDataVisibleColumn>
                                <syncfusion:GridDataVisibleColumn HeaderText="ProductDetails" IsReadOnly="True" MappingName="ProductDetails" AllowSort="False"
                                                                  UpdateMode="PropertyChanged">

                                    <syncfusion:GridDataVisibleColumn.HeaderStyle>
                                        <syncfusion:GridDataColumnStyle HorizontalAlignment="Left" />
                                    </syncfusion:GridDataVisibleColumn.HeaderStyle>
                                    <syncfusion:GridDataVisibleColumn.ColumnStyle>
                                        <syncfusion:GridDataColumnStyle HorizontalAlignment="Left" />
                                    </syncfusion:GridDataVisibleColumn.ColumnStyle>

                                </syncfusion:GridDataVisibleColumn>
                                <syncfusion:GridDataVisibleColumn MappingName="IsActive" IsHidden="True"  />
                            </syncfusion:GridDataTableProperties.VisibleColumns>
                        </syncfusion:GridDataTableProperties>
                    </syncfusion:GridDataRelation.TableProperties>

                </syncfusion:GridDataRelation>
            </syncfusion:GridDataControl.Relations>


        </syncfusion:GridDataControl>


Problem:
 the Relations is not updating the ProductDetails value due to the Conditional Formatting eventhough i have written this line of code
  public MainWindow()
        {
            InitializeComponent();
            this.ImportDataGrid.Model.RefreshWholeRow = true;
        }
<syncfusion:GridDataControl.Relations >
                    <syncfusion:GridDataRelation  RelationalColumn="ProductList"  >

Please let me know how to overcome this problem,if there is no conditionalFormatting it is working fine.


AR Akila Rajaram Syncfusion Team May 20, 2014 12:02 PM UTC

Hi  Sankar,

 

We could not understand your requirement clearly. If you want to refer the row based on condition using Conditional formatting for NestedGird then you have achieve your requirement by setting RefreshWholeRow property to true for ChildModel as in the below code,

 

public MainWindow()

        {

            InitializeComponent();

            this.dataGrid.Model.RefreshWholeRow = true;

            this.dataGrid.Model.Table.RecordExpanded += Table_RecordExpanded;

        }

 

void Table_RecordExpanded(object sender, GridDataValueEventArgs<GridDataRecord> e)

        {

            e.Value.ChildModels[0].RefreshWholeRow = true;

        }

 

If your requirement is different from the above one then please revert us with more details that will help us to provide better solution to meet your requirement.

 

Please refer the below attached sample.

 

Please let us know if you have any questions.

 

Regards,

Akila                


Attachment: sample_d1fa56db.zip

Loader.
Live Chat Icon For mobile
Up arrow icon