[Data Grid] Using cancel = true with beginningEdit not working

Forge Component
Published on 4 Dec (4 days ago) by OutSystems R&D
32 votes
Published on 4 Dec (4 days ago) by OutSystems R&D

Hi All,

I'm sure the problem is due to my misunderstanding but I cant seem to prevent the default behaviour on editable text fields or checkboxes,

I have the need to set text fields and checkboxes to read only programmatically  (both on initial load and when other data on the row changes) the only way I have seen to do this is using the beginningEdit Handler,

from reading the Sample documentation and Wijmo demo site I tried with the following script,

I wasn't sure if I needed to remove the standard handlers first so I tried with and without and it didn't make a difference. I can get the beginningEdit to fire and display the alert and set e.cancel = true,

but even doing this it still continues on and either opens the field in editor or ticks the checkbox

Hoping someone can point me in the right direction, I have logged a support call but so far no response.

Thanks Neil

SyntaxEditor Code Snippet

var beginCellEdit = function(GridId) {
    var _gObj = GridOS.ComponentUtils.getGridObjectById(GridId);
    _gObj.event.beginningEdit = function(s,e) {
        /* Logic to run when [Event Name] triggers */
        var col = s.columns[e.col];
        if (col.binding == 'NewPriceValue') {    
          e.cancel = true;
          alert('items cannot be edited');

Hi Neil,

If you need to programmatically disable the whole column, you can use the property isReadOnly:

theGrid.columns[2].isReadOnly = true;

If you need to disable an specific cell after changing another cell in the same row, you will need some hacking and have an array that will hold the list of lines that are read only. Refer to this jsFiddle to see an example, and see the event handler defined in the line 52:


Hope this helps.

Hi ,

Thank you for the response,

I was able to use the  beginningEdit event successfully ( as the alert being sent)  but the e.cancel = true wasn't being obeyed.

I have received a call back from support and they are investigating a sample app I have given them and I will post their findings here.

I will note that at times the cancel did work on a text field input then other times it failed but at no stage could I get a checkbox input to be cancelled.