This is a migrated thread and some comments may be shown as answers.

BindingValidation Error on Silverlight RAD Grid

6 Answers 78 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ravi
Top achievements
Rank 1
Ravi asked on 05 Dec 2011, 10:16 AM
<telerikGridView:GridViewDataColumn Width="120" DataMemberBinding="{Binding ProposedRSUGrants}"  SortMemberPath="ProposedRSUGrants">
                                        <telerikGridView:GridViewDataColumn.Header>
                                            <TextBlock Text="Proposed RSU Grant # shares" Style="{StaticResource EditableHeader}"/>
                                        </telerikGridView:GridViewDataColumn.Header>
                                        <telerikGridView:GridViewDataColumn.CellTemplate>
                                            <DataTemplate>
                                                <Border Background="LightYellow">
                                                    <TextBlock Margin="0,0,3,0" HorizontalAlignment="Right" Text="{Binding ProposedRSUGrants}"/>
                                                </Border>
                                            </DataTemplate>
                                        </telerikGridView:GridViewDataColumn.CellTemplate>
                                        <telerikGridView:GridViewDataColumn.CellEditTemplate>
                                            <DataTemplate>
                                                <TextBox Text="{Binding ProposedRSUGrants, Mode=TwoWay,NotifyOnValidationError=True, ValidatesOnExceptions=True}" GotFocus="Grid_TextBox_GotFocus" IsEnabled="{Binding StockEligible}"/>
                                            </DataTemplate>
                                        </telerikGridView:GridViewDataColumn.CellEditTemplate>
                                    </telerikGridView:GridViewDataColumn>

in the setter i have the below code
public int ProposedRSUGrants
        {
            get
            {
                return _ProposedRSUGrants;
            }
            set
            {
                if (value != _ProposedRSUGrants)
                {
                    _ProposedRSUGrants = value;
                    isPropertyUpdatedBy_ProposedRSUGrants = true;
  
                    onPropertyChanged(this, "ProposedRSUGrants");
                    if (!isPropertyUpdatedBy_ProposedRSUGrantValueCurrency)
                    {
                        ProposedRSUGrantValueCurrency = _ProposedRSUGrants * Guidelines.DefaultPrice;
                        onPropertyChanged(this, "ProposedRSUGrantValueCurrency");
                    }
  
                    isPropertyUpdatedBy_ProposedRSUGrantValueCurrency = false;
                    CalcWalkawayvalueofproposedRSUs_at8();
                    CalcWalkawayvalueofproposedRSUs_at12();
                    CalcWalkawayvalueofproposedRSUs_at16();
  
                    SetDirty();
                    SetRecalculateDirty();
  
                    //Proposed RSU Grant Value should be with in the Range of RSU GuideLines Value
                    //string strMsgTemplate = "The Proposed RSU Grant cannot be {0} than {1} (Press \"Escape\" to retain the old value)";
                    string strMsgTemplate = "Warning: The Proposed RSU Grant is {0} than {1}";
  
                    if ((value > RSUGuideLineMax) && (value != Guidelines.EQUITY_RANGE_GUIDENCE_DEFAULT_VALUE))
                    {
                        string strMsg = string.Format(strMsgTemplate, "greater", RSUGuideLineMax);
                        throw new InvalidDataException(strMsg);
                    }
                    else if ((value < RSUGuideLineMin) && (value != Guidelines.EQUITY_RANGE_GUIDENCE_DEFAULT_VALUE))
                    {
                        string strMsg = string.Format(strMsgTemplate, "less", RSUGuideLineMin);
                        throw new InvalidDataException(strMsg);
                    }
                    //end of new changes                    
                }                
            }
        }


Hi I have implemented RAD Grid under multiple TABs as attached. In few of the grid i have inline editing enabled based on some business functionality. Now if the user enters some invalid value in the editable column it throws the error from the setter as well as displays the red rectangle with the errro message.

My issue here is, after the error message is poped-up the user can go ahead and click on any of the TABs or the left vertical menu (Tom Fallon). sometimes when the user double clicks on the TAB or Left menu the system is throwing an exception.

What i need is, if there is an exception already shown, the user should not be able to do any further actions unless REFRESH or F5. How can i acheive this.

Thanks,
Shiras

6 Answers, 1 is accepted

Sort by
0
Ravi
Top achievements
Rank 1
answered on 06 Dec 2011, 09:42 AM
Appreciate a quick response.
0
Ravi
Top achievements
Rank 1
answered on 07 Dec 2011, 12:06 PM
Hi,

Can you please let me know the status on this issue.

This issue in our project is a show-stopper and we appreciate a quick response.

Thanks,
Shiras
0
Nedyalko Nikolov
Telerik team
answered on 07 Dec 2011, 12:17 PM
Hello David,

Generally this should be the default behavior unless you didn't modify RadGridView.ActionOnLostFocus property.
RadGridView should place focus in the "invalid" cell when binding validation error occur.
Could you please send me a sample project which I can debug on my side in order to see what is going on?
Thank you in advance.

Greetings,
Nedyalko Nikolov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Ravi
Top achievements
Rank 1
answered on 07 Dec 2011, 03:25 PM
I have not done any modification to RadGridView.ActionOnLostFocus.

I guess the code i have provided in full, I mean the setter and the XAML. now the only thing is to have RadGrid in place. I guess you should be able to do it and let me know.

Let me know if you still need a sample project for this small issue.

Thanks,
Shiras
0
Ravi
Top achievements
Rank 1
answered on 09 Dec 2011, 12:04 PM
Hi Guys,

I am not sure how many times I should send a reminder on my issue ticket.

Appreciate a response without any more reminders.

you may please provide a sample application with what you feel is the right way of coding for my issue.If not please suggest me someway.

Thanks,
Shiras
0
Nedyalko Nikolov
Telerik team
answered on 12 Dec 2011, 09:58 AM
Hello David,

Unfortunately RadGridView cannot control the entire page. What I meant with my previous post is that RadGridView returns focus to the "invalid" cell, but it is beyond RadGridView to stop (prevent) any other action outside of the grid.
However you could use RadGridView.CellValidated event to determinate if there is a validation error and perform an appropriate action.

private void radGridView_CellValidated(object sender, Telerik.Windows.Controls.GridViewCellValidatedEventArgs e)
        {
            if (e.ValidationResult != null && e.ValidationResult.ErrorMessage != null)
            {
                this.radTabControl.SelectedIndex = 0;
            }
        }

Let me know if this does not help.

Greetings,
Nedyalko Nikolov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Ravi
Top achievements
Rank 1
Answers by
Ravi
Top achievements
Rank 1
Nedyalko Nikolov
Telerik team
Share this question
or