ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: stevejacobsen on February 20, 2022, 12:20:41 am

Title: Filters and Listeners in version 8.2.1
Post by: stevejacobsen on February 20, 2022, 12:20:41 am
I am upgrading from version 3.2 to 8.2.1. I read through the all the upgrade instructions and noticed that listeners were discouraged version 5.20. But I'm not finding a solution for how I previously used them. In this case when the user searches for a part #, they are able to press the down arrow and it moves them to the grid. And they can select from the filtered data. If they only have one result in the filtered data, they can press enter and it automatically moves to the grid and selects that item.

But neither of these are working now.

Code: [Select]
           {title: "Part", width: 165, dataIndx: "Part", align: "left", cls: 'result',
            filter: {
                crules: [{condition: 'begin'}],
                listener: [{'keydown': function (evt, ui) {
                            /* Custom filter listeners:
                             *
                             * if the down arrow is pressed the cursor will move to the first row in the grid
                             *
                             */

                            if (evt.keyCode === 40) {
                                $("#inventory_grid").pqGrid("setSelection", {rowIndx: 0});
                            }
                            if (evt.keyCode === 13) {

                                /* if the enter key is pressed and there is only one row of data, the cursor will
                                 * select the row and then use the data to open the edit form
                                 */

                                var data = $("#inventory_grid").pqGrid("pageData");
                                if (data.length === 1) {
                                    $("#inventory_grid").pqGrid("setSelection", {rowIndx: 0});
                                    var rowData = $("#inventory_grid").pqGrid("getRowData", {rowIndx: 0});
                                    editpart(getpartarraybyinventoryid(rowData.InventoryID), 0);
                                }
                            }
                        }, 'keyup': function (evt, ui) {
                            /*
                             * This replicates the default search functions
                             */
                            $("#inventory_grid").pqGrid("filter",
                                    {
                                        oper: 'replace',
                                        data: [
                                            {dataIndx: 'Part', condition: 'begin', value: ui.value}
                                        ]
                                    }
                            );
                        }
                    }
                ]
            }
        },
Title: Re: Filters and Listeners in version 8.2.1
Post by: paramvir on February 21, 2022, 12:12:41 pm
Please use listeners instead of listener and pass correct parameters to filter method.

Code: [Select]
$("#inventory_grid").pqGrid("filter",
                 {
                         oper: 'replace',
                         rules: [
                               {dataIndx: ui.dataIndx, condition: 'begin', value: ui.value}
                         ]
                  }
);

Title: Re: Filters and Listeners in version 8.2.1
Post by: stevejacobsen on February 22, 2022, 07:16:58 am
Thanks, that did what I needed. I caught the listener bit but missed the filter format! Thanks.