Prevent Single click cell-editing

Posted by: peter_murray on 20 March 2020, 6:35 am EST

  • Posted 20 March 2020, 6:35 am EST

    Hello,

    There’s something in this example here that has me confused. Some cells, like those in the country column, can be edited and have their values saved with one click, one press of backspace/delete, or just by typing with the cell selected. Others, like ProductId, cannot have their values edited with delete/backspace; they can be edited after clicking once or by typing with the cell selected, but the new value is not saved and it immediately reverts to whatever value was saved previously.

    I haven’t been able to discern what differentiates these cells but I’m looking to make the cells in my application emulate this is a similar way: to be completely uneditable on a single click by any means, only editable by double clicking.

    So how does the example table accomplish the behavior discussed in the first paragraph, and how can I achieve the behavior I desire in the second?

    https://www.grapecity.com/wijmo/demos/Grid/Overview/purejs

  • Posted 22 March 2020, 5:45 pm EST

    Hi Peter,

    These cells have different behaviors because they are different type of cells. The Country is a simple editable cell whereas the CountryId column is DataMap cell. This means the country column can be edited by typing and can have any string value. But the cells that have DataMap shows a drop-down (the drop-down of ProductId is disabled) and can only have the values provided in the drop-down. That is why it reverts back to its original value because the new value is not in DataMap.

    You may refer to the sample below for more understanding of DataMap:

    https://www.grapecity.com/wijmo/demos/Grid/Columns/DataMaps/purejs

    Also, the CountryId cells cannot be edited by backspace because they are required cells. These cells are of Number type, which are required by default, but since they are using DataMap, string values are shown on these cells.

    By default, all the cells are only editable by double clicking or typing directly into the cells. If you only want the cells to be editable by double clicking, you may disable the quick editing (typing directly in to the cells) by handling the beginningEdit event. Please refer to the sample below:

    https://www.grapecity.com/wijmo/demos/Grid/Editing/QuickEditing/purejs

    I hope this clears your doubts.

    Regards,

    Ashwin

  • Posted 25 March 2020, 7:15 am EST

    Thanks for the explanation! It is greaty appreciated. However, the example provided helped us prevent single-click editing but caused problems in our testing environment.

    So now we have to allow single-click editing: this is okay if we’re entering new data but if we press backspace or delete to clear the cell of data, this is where we run into problems. I’ve been experimenting with the cellEditEnding event to try and force the table into a full-edit/doouble-click-edit mode on pressing backspace/delete but this does not happen. What does happen is that the entry is cleared and the table does not go enter the desired edit mode.

    Is there any more insight you might be able to provide on this?

  • Posted 25 March 2020, 9:40 pm EST

    Hi Peter,

    In the beginningEdit event, you may check whether the key is Backspace or Delete and start the editing of the FlexGrid manually. Please add the following code snippet in the beginningEdit event and let me know if this works for you:

    
    if (e.data && (e.data.key === 'Backspace' || e.data.key === 'Delete')) {        
    	setTimeout(() => s.startEditing(false, e.row, e.col))
    }
    
    

    ~regards

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels