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

6 posts, 0 answers
  1. Damian
    Damian avatar
    1 posts
    Member since:
    Dec 2014

    Posted 05 Mar 2015 Link to this post

    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!
  2. Daniel
    Admin
    Daniel avatar
    2231 posts

    Posted 09 Mar 2015 Link to this post

    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!
     
  3. Daniel Grünberger
    Daniel Grünberger avatar
    55 posts
    Member since:
    May 2008

    Posted 09 Mar 2017 in reply to Daniel Link to this post

    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

  4. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2466 posts

    Posted 13 Mar 2017 Link to this post

    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.
  5. Daniel Grünberger
    Daniel Grünberger avatar
    55 posts
    Member since:
    May 2008

    Posted 19 Mar 2017 in reply to Konstantin Dikov Link to this post

    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

  6. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2466 posts

    Posted 21 Mar 2017 Link to this post

    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.
Back to Top