Welcome to the Xceed Community | Help
Community Search  
More Search Options

Cell Validation

Sort Posts: Previous Next
  •  01-01-2012, 7:34 PM Post no. 31512

    Cell Validation

    I am trying to get custom date validation working on an editable cell.

    Using

                                            <xcdg:Column FieldName="TimeRequired" Title="When Required"   Width="150"  CellEditor="{StaticResource DateTimeEditor}"
                                                         CellContentTemplate="{StaticResource DateTimeCellDataTemplate}" >
                                                <xcdg:Column.CellValidationRules>
                                                            <model:FullTimeCellValidationRule/>
                                                </xcdg:Column.CellValidationRules>
                                            </xcdg:Column>

    The validation rule is called, however the value parameter is the previously valid Date object -. not the invalid string just entered. The unexpected Date object leads to an exception which is picked up and passed as a ValidationResult. The cell then correctly displays the bogus error. Why am I picking up the target value instead of the source?

    I have also tried putting a regular validation rule directly on the TextBox of the CellEditor. This is called with the invalid string, but the cell is not highlighted in error.

    What am I doing wrong?

     

  •  01-03-2012, 4:18 PM Post no. 31513 in reply to 31512

    Re: Cell Validation

    Hi Peter,

    Are you able to send me a small self contained sample application that will replicate this behavior? With this information, I will be able to provide you with a possible solution. You can send the sample application by email to support@xceed.com or you can attach it to this thread by replying to this post, clicking on the "Options" tab and upload your attachment. Please remember that if you will be submitting your sample application, to remove any license keys from your code.


    Marc

    Developer in Technical Support
    Xceed - Multi-talented components - http://xceed.com
  •  01-04-2012, 5:11 PM Post no. 31516 in reply to 31513

    Re: Cell Validation

    Marc,

    I'm not reporting a bug, I'm just confused how you achieve the following:

    What markup do you need to:

    1. Provide your own CellEditor  template (in my case an AutoSelectTextBox)

    2. Provide your own value converter.

    3. Validate only on focus lost, but optionally on PropertyChanged

    4. Indicate the phase that any validation rules are executed. RawProposedValue, Converted value etc.

    5. Make sure Validation.HasError is set at the appropriate level so that errors are presented to the user.

    What is needed is a good example on your web site of a cell editor using TextBox or AutoSelectTextBox. Many users seem totally confused by your examples (which are largely out of date for .Net 4.0) and only target your own controls using the xcdg:CellEditorBinding which only seems to support PropertyChanged validation.

    =====================================================================

    The following nearly works - except the datacell is not flaged in error. The AutoSelectTextBox does get flagged, but this does not stop the WPF validation cycle and the value gets overriden by the original internal value.

             <xcdg:CellEditor x:Key="DateTimeEditor" >
                <xcdg:CellEditor.EditTemplate>
                    <DataTemplate>
                        <xcctrl:AutoSelectTextBox Name="PART_CellEditorBoundControl"
                                 xcdg:CellEditor.HasError="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.HasError),ValidatesOnExceptions=True}"
                                 xcdg:DataCell.IsCellFocusScope="True"
                                Validation.Error="PART_CellEditorBoundControl_Error"                                              >
                            <xcctrl:AutoSelectTextBox.Text>
                                <Binding RelativeSource="{RelativeSource FindAncestor, AncestorType=xcdg:DataCell}"
                                        Path="Content"
                                        Converter="{model:FullTimeConverter}"
                                        UpdateSourceTrigger="LostFocus"
                                        ValidatesOnExceptions="True"
                                         NotifyOnValidationError="True">
                                    <Binding.ValidationRules>
                                        <model:FullTimeValidationRule ValidationStep="RawProposedValue"/>
                                    </Binding.ValidationRules>
                                </Binding>
                                </xcctrl:AutoSelectTextBox.Text>
                        </xcctrl:AutoSelectTextBox>
                        <!--UpdateSourcetrigger allows user to edit values thru invalid states before committing to change-->
                    </DataTemplate>
                </xcdg:CellEditor.EditTemplate>

    Regards

    Peter Wilson

     

     

     

  •  01-11-2012, 4:39 PM Post no. 31548 in reply to 31516

    Re: Cell Validation

    Hi Peter,

    In your first post, you mention that the FullTimeCellValidationRule receives the previous value. This should not be, whether you have a custom editor or not.  But in the second post, you show your custom cell editor, and in it you use again the FullTimeCellValidationRule.  Do you do it at both levels (editor and cell)?  If so, it could well explain why you get the previous value in the FullTimeCellValidationRule at the cell level.

    In anycase, the FullTimeCellValidationRule should receive the right value at the cell level, and should therefore be able to correctly validate the value, and put the cell in the correct state.

    Since this is not the case, a sample application showing this behavior would help us understand the issue. The scenario of your first case, everything should be able to work as expected.


    Marc

    Developer in Technical Support
    Xceed - Multi-talented components - http://xceed.com
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.