Undo dont work on manual cell.edit

I set the grid editable to false because it should only be editable when the user click on a button.

i made it editable by executing this function



        function rowEditMode ( row_id )

        {

            editors = [ ];

            main_grid.forEachCell ( row_id, function ( cell )

                {

                 editors.push ( cell );

                 cell.edit ();

                }

            );        

        }



then turn it back to read only mode executing this function



        function rowReadOnlyMode ()

        {

            for ( var i = 0; i < editors.length; i++ ) editors[ i ].detach ();     

        }



but when cancel link is clicked undo wont work getUndo(). length returns 0 even though I edited a couple of fields in the row



        function undoChanges ()

        {

            var _count = main_grid.getUndo ().length;

            

            alert("undo count "+ _count);

                        

            for ( var i = 0; i < _count; i++ ) main_grid.doUndo ();

            

        }

The undo functionality stores list of updates based on in-grid events.
In your case the edit functionality switched directly on cell level, so there is no any grid-level events generated, and undo functionality can’t collect necessary info.
You can add some code to inform undo functionality about updates.
        function rowReadOnlyMode ()

        {

            for ( var i = 0; i < editors.length; i++ ) {
                    editors[ i ].detach ();     

                    main_grid._onEditUndoRedo(2,row_id,i,editors[ i ].val,editors[ i ].getValue());
             }
        }