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

how to prevent "closeCell" in InCell edit mode when clicking outside the cell

5 Answers 1335 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Damian
Top achievements
Rank 1
Damian asked on 05 Mar 2015, 12:48 PM
Hi,

I have a Kendo Grid and I'm using InCell edit mode. Each cell has a custom editor using the column.editor assignment. I would like to prevent the cell from switching off my editor when the input is invalid. When the user enters an invalid value and then clicks outside the cell, the grid will automatically close the cell for editing and commit whatever value it had. This is far from ideal and I can't figure out a way to prevent it.

In short, I need to disable this "click outside to close editor" feature when the input entered is invalid. I tried using the "cancel" event but that event doesn't fire when clicking outside. It only fires when I explicitly call "closeCell()". I tried all sorts of other hacks like overriding the click handlers of the grid itself but it's either too dirty or just didn't work.

What is the appropriate solution for this?

Thanks!

5 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 09 Mar 2015, 09:29 AM
Hello Damian,

You could use validation for the editors(custom or built-in) if you wish to prevent the cell from being closed when the value is invalid. If you wish to validate the value manually then you should use the save event and prevent the cell from exiting edit mode with the event argument preventDefault method.

Regards,
Daniel
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Daniel Knoll
Top achievements
Rank 1
answered on 09 Mar 2017, 11:33 AM

Hello Daniel,

the current documentation states, that the grid will still exit the edit-mode, when you use preventDefault in the save-event:

e.preventDefault Function
If invoked, prevents the save action. In "incell" editable.mode the edited table cell will exit edit mode. In "inline" and "popup" edit modes, the edit form will remain open.

 

Is there a way to prevent exiting the edit-mode in "incell"-editing?

Best regards

0
Konstantin Dikov
Telerik team
answered on 13 Mar 2017, 07:57 AM
Hi Daniel,

Calling the preventDefault within the save event with InCell editing will prevent the change of the value, but will not keep the cell in edit mode. For keeping the cell opened you need to use the custom validation approach and add the logic for preventing the closing of the cell within that custom validation.


Best Regards,
Konstantin Dikov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Daniel Knoll
Top achievements
Rank 1
answered on 19 Mar 2017, 08:00 PM

Hello Konstantin,

thanks for your answer.

Unfortunately I can't use the custom validation for various reasons. So I need another way to keep the cell open.

Can you provide some hint to prevent the cell from closing?

Best regards

0
Konstantin Dikov
Telerik team
answered on 21 Mar 2017, 03:32 PM
Hi Daniel,

Using the validation or changing the edit mode to InLine/PopUp are the only options that you have, because the Batch editing will close the cell when the input element loses focus and this could not be prevented.


Regards,
Konstantin Dikov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Damian
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Daniel Knoll
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or