Author Topic: How to save data in cell without pressing "tab" or "enter" keys  (Read 2746 times)

dev-ncw

  • Newbie
  • *
  • Posts: 6
    • View Profile
Hello,

I have the grid setup and running. It seems though that in order to save newly entered data in the cell the user has to either hit either the "tab" key or the "enter" key. This however is not so intuitive for the last cell. Last cell in my grid is shipping date with date editor. Users simply select a date and hit save resulting in validation error that says that Shipping date is required (attachment shows this situation).

I've tried the following on the shipping date column:

Code: [Select]
editModel: { keyUpDown: false, onBlur: 'save', saveKey: '' }
Code: [Select]
editModel: { keyUpDown: false, saveKey: '' }
Code: [Select]
editModel: { keyUpDown: false, onBlur: 'save'}
Which failed to work and so I tried the following (which didn't work either):

Code: [Select]
    grid.on("pqgridquiteditmode", function (evt, ui) {
        //exclude esc and tab           
        if (evt.keyCode != $.ui.keyCode.ESCAPE && evt.keyCode != $.ui.keyCode.TAB) {
            grid.pqGrid("saveEditCell");
        }
    });

In general is it possible to save data to a cell when it loses focus?

Thanks

dev-ncw

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: How to save data in cell without pressing "tab" or "enter" keys
« Reply #1 on: August 04, 2016, 10:27:05 pm »
For those who stumble upon this post looking for answers to similar problem, this is what worked for me (for Pqgrid free V 2.0.4).

Code: [Select]
    $(document).on("blur", ".pq-editor-focus", function (evt) {
        var $grid = $(this).closest(".pq-grid");
        $grid.pqGrid("saveEditCell");
       
    });

As a note, do not have separate code for Cellbeforesave event along with above code as this will result in infinite recursion.

Hope this helps somebody.

Thanks to Paramquery admins for answering a similar question in an older post.