Last row is not saved when AddRow not visible

Posted by: greg.frazer on 9 October 2017, 1:53 pm EST

    • Post Options:
    • Link

    Posted 9 October 2017, 1:53 pm EST

    I have turned off the AddRow so it is not in the grid

    When I edit a cell on the grid and press the Enter key, the row is not saved.

    I have tracked this down to:

    1. the file: wijmo.grid.ts
    2. the method: constructor
    3. the call: grid.selectionChanging.addHandler
    4. the if statement: if (e.row != grid.selection.row)

      as there is no AddRow and this is the last row, therefore:

      e.row == grid.selection.row

      so this never gets called:

      self._commitRowEdits();

    How do I get this to be called when:

    e.row == grid.selection.row

    Wijmo FlexGrid 5.20151.51

    Regards

    GregJF

  • Posted 9 October 2017, 5:56 pm EST

    Hi Greg,

    You can use enter key for commit changes or by just moving to selection to the different row. Please refer to the fiddle with 5.20151.51 (http://jsfiddle.net/mkgupta911/y9Lj6os0/4/).

    You may use latest build 5.20172.359 by setting keyActionTab to “CycleOut”, this will gets out of FlexGrid if the selected cell is last cell and tab is pressed.

    Please refer to the fiddle(http://jsfiddle.net/mkgupta911/y9Lj6os0/5/) for the same.

    ~Manish Kr Gupta

  • Posted 10 October 2017, 9:52 am EST

    With all due respect, I think you miss understand the issue.

    I know that I can tab(Shift+tab) or mouse off the row to save it and that does work

    But when the Enter is pressed the _commitRowEdits() is not called because e.row == grid.selection.row

    This is NOT the case if enter is press on any row other than the last, when the AddRow is not present

    This is NOT the case if enter is press on the last data row , when the AddRow is present

    So the behavior for my users is different in this edge case.

    I wish the behavior (ie press enter key) to be the same in ALL similar cases

    regards

    GregJF

  • Posted 10 October 2017, 4:23 pm EST

    Hi Gref,

    We are sorry, we are unable to replicate the issue at our end with the latest build 5.20172.359.

    Steps followed to Reproduce the issue:

    Open http://jsfiddle.net/mkgupta911/y9Lj6os0/5/ in Edge/Chrome

    Go to the last Row

    Start editing and press enter for commit changes

    The Edit mark went away from RowHeaders which shows that edit has been committed. Also, the row values get updated.

    If still issue exists, please let me know with the sample so that We can replicate at our end and assist you accordingly.

    ~Manish Kr Gupta

  • Posted 16 October 2017, 9:05 am EST

    Manish

    With all due respect; your example does not show that the “self._commitRowEdits” of the _EditHandler class in the wijmo.grid.ts file was actually called.

    I get the same UI behavior that your example illustrates, but when debugging I see that in the constructor of _EditHandler class, there is a grid.selectionChanging event handler which contains an if statement:

    if (e.row != grid.selection.row) {
             self._commitRowEdits();
    }
    

    When the allowAddRow is set to false; then the above if statement is false and

    self._commitRowEdits(); of the _EditHandler class NEVER gets fired.

    Can you debug your code to see id this is the case for you, please.

    I cannot debug your example as the wijmo.grid.ts gas been minified to wijmo.grid.min.js

    Regards

    GregJF

  • Posted 17 October 2017, 6:20 pm EST

    Hi Greg,

    I’ve been trying to recreate this. Can you share a fiddle or step to reproduce this?

    ~nilay

  • Posted 31 October 2017, 12:43 pm EST

    nilay

    How can I do that and not post to fiddle the un-minfied Wijmo.grid.js file?

    Here is the code from a chrome debugger window (so it is JS):

     // finish editing when selection changes (commit row edits if row changed)
                    g.selectionChanging.addHandler(function (s, e) {
                        if (_this.finishEditing()) {
                            var oldrow = g._selHdl.selection.row;
                            if (oldrow != e.row) {
                                var len = g.rows.length, olditem = oldrow > -1 && oldrow < len ? g.rows[oldrow].dataItem : null, newitem = e.row > -1 && e.row < len ? g.rows[e.row].dataItem : null;
                                if (olditem != newitem) {
                                    _this._commitRowEdits();
                                }
                            }
                        }
                        else {
                            e.cancel = true; // staying in edit mode, keep selection
                        }
                    });
    

    The line: “if (oldrow != e.row) {” is the issue.

    If you click Enter or move to another cell on the same line, this if statement will be false and the line: “_this._commitRowEdits();” will never get fired.

    But we want it to fire on clicking the Enter button

    Regards GregJF

  • Posted 31 October 2017, 5:55 pm EST

    Hi Greg,

    Yes, you are right. In this case, “_this._commitRowEdits()” will not be triggered. But on pressing enter key, the following code gets execute that commit the changes:

    case Key.Enter:
                       handled = this._performKeyAction(g.keyActionEnter, shift);
                       if (!shift && ecv && ecv.currentEditItem != null) {
                           g._edtHdl._commitRowEdits();
                       }
    

    Hope it clears!

    ~Manish

  • Posted 9 November 2017, 8:46 am EST

    Manish

    Thanks for point that out.

    Yes it does finish this thread

Need extra support?

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

Learn More

Forum Channels