jQWidgets Forums

jQuery UI Widgets Forums Grid Confirmation on editing the grid

This topic contains 2 replies, has 2 voices, and was last updated by  ei7024 10 years, 8 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • Confirmation on editing the grid #59445

    gonley
    Participant

    I use dropdownlist as editor on the grid. When I want to update the dropdownlist item, I want to make a confirmation to ask user for confirmation whether they want to update this value. If not then remain the old value, else update new selected dropdownlist value. I try use cellendedit and cellvaluechanging but the value is automatically updated before the confirmation is made because it is bind to the database. How to achieve this?

    Confirmation on editing the grid #59449

    ei7024
    Participant

    I was about to post a same request and would also like to know the answer to this question please!

    In my case the cellendedit function is called at the time of select in the initeditor: function ()

    editor.on('select',function(){ $("#jqxgrid").jqxGrid('endcelledit', row, "datafield", false);});

    the following is the cellendedit function()

    $("#jqxgrid").on('cellendedit', function (event) {
        var column = args.datafield;
        var row = args.rowindex;
        var value = args.value;
        var oldvalue = args.oldvalue;
        
        r = -1;
        
        if(oldvalue != '')
        {
            conf = confirm('Are you sure?');
        }
        else
        {
            conf = true;
        }
        
        if(conf)
        {
            //PROCEED WITH CHANGES AND REFRESH GRID
        }
        else
        {
            //CANCEL REQUEST AND SET COLUMN TO OLD VALUE
            $("#jqxgrid").jqxGrid('setcellvalue', row, column, oldvalue); //<------DOES NOT SET THE VALUE
        }
        
        alert(oldvalue + '---->' + value);
    });
    Confirmation on editing the grid #59452

    ei7024
    Participant

    btw gonley I think this may come in handy as a solution;

    
    if (!oldvalue) {conf = true;} else {conf = confirm('Are you sure ?');}
    if(conf == true) 
    { // IF TRUE
      alert(newvalue);
      return newvalue;
    } else 
    {
      // IF FALSE - SHOW OLD VALUE
      alert(oldvalue);
      return oldvalue;
    }

    the above code is added in the cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { //ABOVE CODE }
    and then your code to update or not in the $(“#jqxgrid”).on(‘cellendedit’, function (event) {}

    If the user clicks cancel then the cellendedit will have newvalue = oldvalues…..

    Hope it helps!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.