Author Topic: Cannot read properties of undefined (reading 'pq_hidden')  (Read 1032 times)

swapnilsu

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 4
    • View Profile
Cannot read properties of undefined (reading 'pq_hidden')
« on: January 12, 2022, 06:56:33 pm »
Hi Team,

When I have implemented PQ grid on my project its working fine for other functionality but when I have created new product by clicking on new product button the new row is inserted in grid and first cell showing in edited form its working fine but when i have changed edited cell to something different its getting issue Cannot read properties of undefined (reading 'pq_hidden')

below is the code

This is working with grid.editFirstCellInRow({ rowIndx: ri });   After try to remove the row

{
            type: 'button', icon: 'ui-icon-plus', label: 'New Product', cls: 'newProductBtn', listener: function () {
                if (checkUserSessionActive()) {
                    var grid = this;
                    var len = PhQty === undefined ? 1 : PhQty;
                    newRows = pqVS.data.filter(function (value) {
                        return value.deleteOption == true;
                   
                    });
                    newRowsCount = parseInt(newRows.length) + parseInt( len);
                    if (newRowsCount<= 200) {
                     
                        for (let i = 0; i <= len - 1; i++) {
                            var obj = grid.getViewPortIndx(),
                                initV = obj.initV;
                            //append empty row at beginning of viewport.                           
                            rowData = { "state": true, "RLSKU":0, "deleteOption": true, "newRow": true } //empty row

                            var ri = grid.addRow({ newRow: rowData, checkEditable: true, rowIndx: initV });
                           
                            grid.scrollRow({ rowIndxPage: ri }, function () {
                              grid.editFirstCellInRow({ rowIndx: ri });
                            });
                           
                        }
                       
                    }
                   
                }
            }
        }

This code is getting issue with grid.editCell({ rowIndx: ri, dataIndx: "CITEMD" })  After try to remove the row

{
            type: 'button', icon: 'ui-icon-plus', label: 'New Product', cls: 'newProductBtn', listener: function () {
                if (checkUserSessionActive()) {
                    var grid = this;
                    var len = PhQty === undefined ? 1 : PhQty;
                    newRows = pqVS.data.filter(function (value) {
                        return value.deleteOption == true;
                   
                    });
                    newRowsCount = parseInt(newRows.length) + parseInt( len);
                    if (newRowsCount<= 200) {
                     
                        for (let i = 0; i <= len - 1; i++) {
                            var obj = grid.getViewPortIndx(),
                                initV = obj.initV;
                            //append empty row at beginning of viewport.                           
                            rowData = { "state": true, "RLSKU":0, "deleteOption": true, "newRow": true } //empty row

                            var ri = grid.addRow({ newRow: rowData, checkEditable: true, rowIndx: initV });
                           
                            grid.scrollRow({ rowIndxPage: ri }, function () {
                                grid.editCell({ rowIndx: ri, dataIndx: "CITEMD" })
                            });
                           
                        }
                       
                    }
                   
                }
            }
        }

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Cannot read properties of undefined (reading 'pq_hidden')
« Reply #1 on: January 12, 2022, 08:21:35 pm »
your code logic doesn't seem right. addRow, scrollRow, editFirstCellInRow methods should not be called in a loop.

addRow method can be used only once to insert multiple rows https://paramquery.com/pro/api#method-addRow

Please move the above methods outside of the loop and kindly share a jsfiddle if the issue is still not resolved.