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

Cannot exit InPlace editor

2 Answers 101 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Raulis
Top achievements
Rank 1
Raulis asked on 06 Sep 2016, 02:22 PM

I've been trying to implement a RegularExpressionValidator for a textbox in my RadGrid. Edits and Inserts happen using the InPlace editor. They are not automatic, I deal with them via code. If I go into Edit Mode I cannot exit Edit Mode or do anything until I fill in the empty fields in the InPlace Editor and either use the Insert or Cancel command. Using the debugger I've determined that no postbacks happen while the grid is in edit mode and there are empty fields in the inplace editor. Not quite sure what to do, cannot find similar issues in the forums.

 

This is my OnDataBound event that implements the RegularExpressionValidator:

 

            'if the grid is currently being edited
            If e.Item.IsInEditMode Then
                ToggleControlVisability(e)
                SetDefaultRateValue(e)

                Dim eItem = TryCast(e.Item, GridEditableItem)
                Dim editor = TryCast(eItem.EditManager.GetColumnEditor("rate"), GridTextBoxColumnEditor)
                Dim cell = TryCast(editor.TextBoxControl.Parent, TableCell)
                Dim rev = New RegularExpressionValidator()
                rev.ControlToValidate = editor.TextBoxControl.ID
                rev.ValidationExpression = "[0-9]*\.?[0-9]*"
                rev.CssClass = "text-danger"
                rev.ErrorMessage = " Please provide a valid number."
                cell.Controls.Add(rev)
            End If

 

 

My Cancel command (which does not get executed):

 

        ToggleCommandColumns()
        rgJobItems.MasterTableView.ClearEditItems()
        rgJobItems.Rebind()

 

 

ToggleCommandColumns is a custom function that swaps button visibility so it should not be affecting anything. Same goes for ToggleControlVisability, it just makes some controls visible on the page. 

I only started encountering this issue when I put in a RegularExpressionValidator. If I take it out, it works fine (I can cancel the editor at any time).

Any support would be appreciated. 

2 Answers, 1 is accepted

Sort by
0
Accepted
Viktor Tachev
Telerik team
answered on 09 Sep 2016, 07:41 AM
Hello Raulis,

The behavior you are seeing is likely caused by the validators. If the entered values are not valid the validator will prevent postback.

In order to avoid that you can use ValidationGroups. Set one group for the RegularExpressionValidator and the Update/Insert button. For the Cancel button you can set the CausesValidation property to false.


Regards,
Viktor Tachev
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Raulis
Top achievements
Rank 1
answered on 09 Sep 2016, 11:20 AM
Perfect, exactly what I needed. The thought of changing the "CausesValidation" value just skimmed past my head. Everything's working as intended now, thanks again.
Tags
Grid
Asked by
Raulis
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Raulis
Top achievements
Rank 1
Share this question
or