Home Forums WPF controls Xceed DataGrid for WPF How to set validation on stat row cell? (Or, entire grid).

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #40361 |

    I have a stat row in the grid footer that adds a column. All rows should add to 100%. If they don’t, I’d like to show an error indicator around the stat cell, and a tooltip somewhere, just as if a regular grid cell were invalid. I can’t see how to do that.

     Alternatively, I could maybe show an error indicator around the entire grid, or something else. Any ideas appreciated.

    Imported from legacy forums. Posted by James (had 2649 views)

    User (Old forums)
    Member
    Post count: 23064

    I tried adding a cell validation rule to the stat cell, as below, but it doesn’t work (my rule never gets called). I still need help with this, please. Again, if the total exceeds 100%, then I’d like to show an error around the stat cell, with a tooltip, just as with a regular cell.

     

    <xcdg:TableflowView.FixedFooters>
        <DataTemplate>
            <xcdg:StatRow>
                <xcdg:StatCell FieldName=”Percentage” ResultConverter=”{StaticResource ResourceKey=percentageConverter}” ResultPropertyName=”percentage_sum”>
                    <xcdg:StatCell.CellValidationRules>
                        <StaticResource ResourceKey=”percentageRule” />
                    </xcdg:StatCell.CellValidationRules>
                </xcdg:StatCell>
            </xcdg:StatRow>
        </DataTemplate>
    </xcdg:TableflowView.FixedFooters>
     

     

     

    Imported from legacy forums. Posted by James (had 260 views)

    Xceed Support
    Member
    Post count: 5658

    Hi James, 

     

    Try putting a DataTrigger linked to the data of the StatCell to modify the display of the statCell as desired.  

    It should look something like this:

            <DataTrigger Binding=”{Binding RelativeSource={RelativeSource Self}, Path=(xcdg:DataGridControl.StatContext).myStat_ResultPropertyName}” Value=”100″>

                <Setter Property=”MyProperty” Value=”MyValue”/>

            </DataTrigger>

     

    I hope it will helps you with your project. 

    Imported from legacy forums. Posted by Sebastien [Xceed] (had 211 views)

    User (Old forums)
    Member
    Post count: 23064

    What property would I be setting on the stat cell? I am trying to get the stat cell to show the same red border and tooltip that a regular grid cell does when it is in error.

    Imported from legacy forums. Posted by James (had 279 views)

    Xceed Support
    Member
    Post count: 5658

    Any member that is available on a StatCell available here: http://doc.xceedsoft.com/products/XceedWpfDataGrid/Xceed.Wpf.DataGrid.v4.3~Xceed.Wpf.DataGrid.StatCell_members.html

    In your case, I guess it would be Background, BorderBrush, BorderThickness and Tooltip.

    If you use your own Template, you can also specify any properties that are available within that template.

    Imported from legacy forums. Posted by Sebastien [Xceed] (had 315 views)

    User (Old forums)
    Member
    Post count: 23064

    Do you mean in the triggers collection of the stat cell? When I try this:

    <xcdg:StatCell.Triggers>

        <DataTrigger Binding=”{Binding RelativeSource={RelativeSource Self}, Path=(xcdg:DataGridControl.StatContext).percentage_sum}” Value=”120″>
            <Setter Property=”Background” Value=”Green”/>
        </DataTrigger>
    </xcdg:StatCell.Triggers>
     

     I get this error:

     Cannot find the static member ‘BackgroundProperty’ on the type ‘ContentPresenter’

     

    By the way, please don’t forget my original goal – to show an “error” with the stat cell content in the same way as an error with a regular cell. Normally with WPF controls the red border is done with the adorner layer, right? (I don’t know about Xceed data grid cells).

    Imported from legacy forums. Posted by James (had 391 views)

    Diane [Xceed]
    Moderator
    Post count: 1353

    Hi James,

    You will need to use the DataTrigger as part of a Style that targets StatCells. I also tried it directly in the StatCell and couldn’t get it to work, but with the following Style it works just fine.

    For example:

       <local:IsStatTotalValidConverter x:Key=”IsStatTotalValid” />

       <Style TargetType=”{x:Type xcdg:StatCell}”>
          <Style.Triggers>
             <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                   <Condition Binding=”{Binding RelativeSource={RelativeSource self}, Path=FieldName}”
                                    Value=”UnitsInStock” />
                   <Condition Binding=”{Binding RelativeSource={RelativeSource self}, Path=Content, Converter={StaticResource IsStatTotalValid}}”
                                    Value=”False” />
                </MultiDataTrigger.Conditions>

                <Setter Property=”Foreground” Value=”Red” />
                <Setter Property=”Background” Value=”Yellow” />
                <Setter Property=”BorderBrush” Value=”Red” />
                <Setter Property=”BorderThickness” Value=”2″ />
                <Setter Property=”ToolTip” Value=”Total is not 100%” />
             </MultiDataTrigger>
          </Style.Triggers>
       </Style>

     

    Imported from legacy forums. Posted by Diane [Xceed] (had 364 views)

    User (Old forums)
    Member
    Post count: 23064

    I couldn’t get the multitrigger to work, even though I changed the Path on the first condition to my field name. My converter never got called. However, I deleted this condition (and also converted to a DataTrigger, since there was only one condition now), and gave the style a key and set the style on my stat cell:

    <Style x:Key=”statCellStyle” TargetType=”{x:Type xcdg:StatCell}”>
        <Style.Triggers>
            <DataTrigger Binding=”{Binding RelativeSource={RelativeSource self}, Path=Content, Converter={StaticResource ResourceKey=percentageTotalValidConverter}}” Value=”False”>
                <Setter Property=”BorderBrush” Value=”Red” />
                <Setter Property=”BorderThickness” Value=”1″ />
                <Setter Property=”ToolTip” Value=”Total is not 100%” />
            </DataTrigger>
        </Style.Triggers>
    </Style>
     

     Style=”{StaticResource ResourceKey=statCellStyle}”

    This works! Thanks for all the help!

     Jim

     

    Imported from legacy forums. Posted by James (had 1534 views)

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.