Author Topic: Disposing of cellSave in an Autocomplete inline editor.  (Read 1910 times)

mcburley

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 5
    • View Profile
Disposing of cellSave in an Autocomplete inline editor.
« on: August 15, 2017, 02:00:16 am »
Using the cellSave inside the autocomplete from the demo. Used to update other cells in the row.
The issue I'm having is that I move to another row and update a different cell (not one with the autocomplete init) the previous values are updating on the current row. Either I'm not using cellSave correctly or I need to dispose of the cellSave? Thanks in advance for any help or advice.

        function autocomp(choicedata) {
            $inp.autocomplete({
                selectItem: { on: true }
                        , source: choicedata
                        , select: function (event, ui) {
                            $("#grid_editing").pqGrid({
                                cellSave: function (event, uid) {
                                    //   console.log(ui);
                                    rwindx = uid.rowIndx;
                                    var value = ui.item.value;
                                    var label = ui.item.label;
                                    if (mycol === 'Location') {
                                        var LocID = ui.item.value;
                                        var Location = ui.item.label;
                                        $("#grid_editing").pqGrid("updateRow", { rowIndx: rwindx, row: { "LocationID": LocID, "Location": Location } });
                                    }
                                    else if (mycol === 'UOMDESC') {
                                        var UOMID = ui.item.value;
                                        var UOMDESC = ui.item.label;
                                        $("#grid_editing").pqGrid("updateRow", { rowIndx: rwindx, row: { "UOMID": UOMID, "UOMDESC": UOMDESC } });
                                    }
                                    return false;
                                }  // END CellSave
                            })
                        },
                selectItem: { on: false }, //custom option
                highlightText: { on: true }, //custom option
                minLength: 0
            }).focus(function (event, ui) {
                //open the autocomplete upon focus   
                $(this).autocomplete("widget").attr('style', 'max-height: 300px; overflow-y :auto; overflow-x: hidden');
                $(this).autocomplete("search", "");
            });

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Disposing of cellSave in an Autocomplete inline editor.
« Reply #1 on: August 15, 2017, 04:59:45 pm »
This is incorrect / improper usage of cellSave. You are facing that issue because of the closure and please avoid global variables.

Here is an example on how to use cellSave.

https://paramquery.com/pro/demos/cascade_select