Option to disable double click to edit when Mode is set to Read with Inline-Editing

  • 1
  • Idea
  • Updated 4 months ago
I have a use case that needs this functionality.

Is there a way to disable this via js?
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb

Posted 4 months ago

  • 1
Photo of John Dahlberg

John Dahlberg, Champion

  • 2,442 Points 2k badge 2x thumb
Use this as a snippet field renderer.  Note that this doesn't handle hiding the pencil icon on hover, but this is the logic to prevent the field from entering into edit mode on a double click.  With this method, If you add an edit button and use the declarative action to run a component action it will still open up edit access on the field.  Setting the field to read-only will disable the component action from opening edit access altogether.



var field = arguments[0],    
    value = arguments[1],
    cellElem = field.element;
    $ = skuid.$;
    function noclick(evt){
        console.log(evt);
        evt.preventDefault();
        return false;
    }
skuid.ui.fieldRenderers[field.metadata.displaytype][field.mode](field,value);
cellElem.on('dblclick',noclick);
Photo of John Dahlberg

John Dahlberg, Champion

  • 2,442 Points 2k badge 2x thumb
Also, a declarative option would be to add two copies of the field to the field editor / table and use rendering logic to toggle between them.  You can setup a ui-only field to track your mode selection for the rendering logic.  Then say in an edit button, you would change the mode of the ui field to switch which field is displayed.  
(Edited)
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Hmmm ... I'd like for this to be a universal thing for all fields on the page. Setting each field to use this would be impractical.

I have a global field renderer code that I'll extend with this.
Photo of John Dahlberg

John Dahlberg, Champion

  • 2,442 Points 2k badge 2x thumb
I'd love to see that solution.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Me too. ;)
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Got it working with one minor change.

evt.stopImmediatePropagation();
instead of
evt.preventDefault();

Here's the globalFieldRenderer code.