Author Topic: Prompting for a confirmation after a cell edit  (Read 3206 times)

sudo

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 12
    • View Profile
Prompting for a confirmation after a cell edit
« on: April 16, 2014, 08:04:06 pm »
How can I confirm saving a change on a cell edit once they have clicked out of that cell.  Tried this to no avail:

    grid.on("pqgridquiteditmode", function (evt, ui) {
        //exclude esc and tab
        if (evt.keyCode != $.ui.keyCode.ESCAPE && evt.keyCode != $.ui.keyCode.TAB) {
            saveChange();
        }
    });

    // dialog for saving the changes
    function saveChange() {
        $("#dialog-confirm-save").dialog({
            resizable: false,
            height: 140,
            modal: true,
            buttons: {
                "Save Changes": function () {
                    grid.pqGrid("saveEditCell");
                    $(this).dialog("close");
                },
                Cancel: function () {
                    grid.pqGrid('quitEditMode');
                    $(this).dialog("close");
                }
            }
        });
    }


 

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Prompting for a confirmation after a cell edit
« Reply #1 on: April 16, 2014, 09:25:39 pm »
Your post is similar to this one http://paramquery.com/forum/index.php?topic=359.msg2583#msg2583

you can delegate blur event to the cell, sample code is provided in this post

http://paramquery.com/forum/index.php?topic=359.msg3100#msg3100

Please let me know whether it solves your requirement.

Edit
----------------------------------------------------
Please ignore the above. It would only ensure a call to quitEditMode when you click outside the grid but it won't let you pause once quitEditMode is initiated. Let me check whether it's possible at all and I would share the details with you..

« Last Edit: April 16, 2014, 09:38:42 pm by paramquery »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Prompting for a confirmation after a cell edit
« Reply #2 on: April 17, 2014, 11:22:31 am »
sudo

Your code is not working because jQueryUI dialog can't pause the execution of javascript after the dialog is opened. So when you show the dialog, code execution proceeds further, editor is destroyed and there is no going back after that.

Though you can do it with confirm function because it holds up the execution of js.

Code: [Select]
// dialog for saving the changes
    function saveChange() {
            var ans = confirm("Do you want to save?");
            if (ans) {
                grid.pqGrid("saveEditCell");
            }
    }
« Last Edit: April 17, 2014, 11:24:47 am by paramquery »