Author Topic: Exception throws , cell editing not properly quitting.  (Read 328 times)

mraj

  • Newbie
  • *
  • Posts: 46
    • View Profile
Exception throws , cell editing not properly quitting.
« on: May 02, 2024, 09:52:59 am »
When I click a new cell, while a cell  is in editing mode. It is not properly, quitting, It throws error as

------------------------------------------------------------------------------------------------------------
jquery.js:8392 Uncaught TypeError: type.indexOf is not a function
    at Object.trigger (jquery.js:8392:13)
    at HTMLInputElement.handler (jquery.js:5477:44)
    at HTMLInputElement.dispatch (jquery.js:5233:27)
    at elemData.handle (jquery.js:5040:28)
    at Object.trigger (jquery.js:8461:12)
    at jQuery.fn.init.triggerHandler (jquery.js:8545:24)
    at d.blurEditor (pqgrid.min.js:11:11104)
    at a.generateView (pqgrid.min.js:9:26917)
    at i.refresh (pqgrid.min.js:13:16018)
    at d.refresh (pqgrid.min.js:11:6400)

------------------------------------------------------------

*** The above error repeatedly coming.

--------------------------------------------------------------

below  are my configurations, and code

1)

editModel: {
                        clicksToEdit: 1,
                        keyUpDown: true,
                        validate: true,
                        invalidClass: 'pq-cell-red-tr pq-has-tooltip', //not working
                        warnClass: 'pq-cell-blue-tr pq-has-tooltip' // not working
                    },

2)
 cellSave: function (evt, ui) { // when changes made in the grid it will trigger / change formulas column values                     
                        this.refresh(); // refreshes the summary data


3)
$("#grid_wire_details").pqGrid({

                    editorEnd: function (event, ui) {
                        rd = ui.rowData;
                        if (ui.colIndx == 5 && rd.ahead_back_same == "Yes") {
                            rd.back_name = rd.ahead_name;
                            rd.back_dia = rd.ahead_dia;
                            rd.back_unit_wt = rd.ahead_unit_wt;
                            rd.back_no_of_wire = rd.ahead_no_of_wire;
                            $("#grid_wire_details").pqGrid("refresh");
                        }
                        else if (ui.colIndx == 5 && rd.ahead_back_same == "No") {
                            rd.back_name = null;
                            rd.back_dia = null;
                            rd.back_unit_wt = null;
                            rd.back_no_of_wire = null;
                            $("#grid_wire_details").pqGrid("refresh");

                        }

                    }


Please provide a clarification.

Thanks in Advance.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6255
    • View Profile
Re: Exception throws , cell editing not properly quitting.
« Reply #1 on: May 02, 2024, 02:43:52 pm »
Remove $("#grid_wire_details").pqGrid("refresh"); from editorEnd event and let me know whether it solves the issue.

mraj

  • Newbie
  • *
  • Posts: 46
    • View Profile
Re: Exception throws , cell editing not properly quitting.
« Reply #2 on: May 03, 2024, 09:38:01 am »
The column mentioned (ahead_back_same) is a Select option, with drop down values,
{
                        title: "AHEAD / BACK SAME", dataIndx: "ahead_back_same", dataType: "string",
                        align: "center", halign: "center", width: 125, editor: {
                            type: 'select', options: [{ "Yes": "Yes" }, { "No": "No" }]
                        }
}

If I remove the  $("#grid_wire_details").pqGrid("refresh") line, then the grid doesn't refreshes and the changed values are not reflected.


The errors often comes, after/at  the cellSave Event. There is also one refresh present.


So Instead of refreshing entire grid, tried refreshing the particular row, using RefreshRow method. at both places CellSave, and EditorEnd events. It seems the errors which are coming reduced almost.

For this scope, it is properly working. need to check further for other areas/scope.

Thanks.




paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6255
    • View Profile
Re: Exception throws , cell editing not properly quitting.
« Reply #3 on: May 03, 2024, 04:15:12 pm »
using refresh() or refreshRow() for column dependencies is a bad practice.

Please check this example https://paramquery.com/demos/grid_formula for column dependencies.

mraj

  • Newbie
  • *
  • Posts: 46
    • View Profile
Re: Exception throws , cell editing not properly quitting.
« Reply #4 on: May 05, 2024, 03:08:19 pm »
Thank you.Will try further other ways.

mraj

  • Newbie
  • *
  • Posts: 46
    • View Profile
Re: Exception throws , cell editing not properly quitting.
« Reply #5 on: July 30, 2024, 04:45:59 pm »
Hi please reply, this is the function i written in the column definition

{
                                title: "Name (Based on Wind Pressure)", dataIndx: "back_name", dataType: "string", align: "left", halign: "center", width: 485,
                                editable: function (ui) {
                                    if (ui.rowData.ahead_back_same == 'Yes') {
                                        return false;
                                    } else { return true;}
                                }
                            }



unable to copy paste, if editable function is given as above.

please provide a workaround.

getting error like this.

Uncaught TypeError: Cannot read properties of undefined (reading 'ahead_back_same')
    at $.<computed>.<computed>.editable (WireLoadCalculation.aspx:387:52)
    at d.isEditableCell (pqgrid.min.js:10:29470)
    at d._digestData (pqgrid.min.js:11:15042)
    at h.paste (pqgrid.min.js:15:14253)
    at pqgrid.min.js:15:15078

Since while copying new rows from excel, the ui does'nt have ahead_back_same and so undefined.






Also, tried for addClass in editorEnd event
this.addClass({ rowIndx: ui.rowIndx, dataIndx: 'back_name', cls: 'disabled' });

it is not working

Edited :

found one way, Changed condition to  : ui.rowData?.ahead_back_same !== undefined,

Please specify any other ways


« Last Edit: July 30, 2024, 06:25:14 pm by mraj »