Recent Posts

Pages: [1] 2 3 ... 10
1
Help for ParamQuery Pro / Do not show the message "No rows to display"
« Last post by jplevene on January 19, 2025, 02:16:47 am »
When a grid has no data, I want to hide the text "No rows to display" that appears in some grids.  How do I do this withou changing the locale files as I don't want to do this for all grids?
2
1) There are checkNodes and unCheckNodes methods but no toggle function. Checked rows can be found out by checking chk property of rows.

if( rowData.chk ) //checked rows.

you can pass rows to be checked to checkNodes and rows to be unchecked to unCheckNodes

2) You can use either getCheckedNodes() method of Checkbox object or check chk property of individual rows to get list of checked rows.
4
Your response worked great, Thank you!

I have 2 followup questions -

1. How to I make this button toggle the checkbox on/off.  Right now, it only checks the boxes based on the page filter.

2. I have this javascript function (below) that currently passes a list of rows that remain in the grid (based on grid filtering).  How do I get the list of grid rows that are only checked?

    $("#btnSubmit").click(function () {
        var pFASIDs = "";
        var grid = $("#grid_jsonp").pqGrid("instance");
        var selectedRows = grid.pageData().filter(function (row) {
            return row.FASActivity.length > 1;
        });
        // Extract the IDs of selected rows
        var selectedIDs = selectedRows.map(function (row) {
            return row.FASActivity;
        });
        pFASIDs = selectedIDs.join(","); ;

        window.location.href = '/CCRSearch/Reports/Index?LayoutId=180&IDs=' + pFASIDs;

    });
5
Please use dataIndx of the Checkbox column instead of "selected". and pass matchingRows  instead of matchingIndices

Code: [Select]
grid.Checkbox( "FASActivity" ).checkNodes( matchingRows );
6
If your only goal is to set default values for newly added rows, then rowTemplate is the right fit.
7
I just discovered rowTemplate and managed to use it to set default values ​​for rows added with paste. I even removed the default value assignment from addRow as it was no longer needed.

It seems that rowTemplate does not affect my existing rows because I set the default values ​​to '' or 0 in the dataModel.

I will still take a look at beforeValidate and change things as you suggested. Thanks for the suggestion!
8
beforeValidate and change are universal events which fire irrespective of the origin.

https://paramquery.com/pro/api#event-beforeValidate

https://paramquery.com/pro/api#event-change

ui.addList length can be checked in the event listener for newly added rows.
9
Hello,

I can perform various operations when adding rows using the addRow method. However, sometimes I use copy-paste to add multiple rows, and in this case, the addRow method is not triggered.

I tried using the beforePaste event, but it executes for all rows, including the existing ones that are not newly added.

What I need is an event that triggers only when a new row is added to the grid, whether through addRow or paste functionality. Is there something like a beforeRowAdd event or any alternative to achieve this?



This function "GridNew()" assigns default values to new rows.
I use it to add new rows and set default values for them, but it does not work for rows added via paste.

The goal is to make it work for rows added through paste as well.


Code: [Select]
window.GridNew = function () {
 
    function applyDefaultValues(rowData) {
        var defaultValues = { type: 1, code: 'newCode',quantity:1 };
        return Object.assign({}, defaultValues, rowData);
    }

    // Adding a new row
    var newRowData = applyDefaultValues({}); // Apply default values

    if (localStorage.getItem('qpRowBottom') == 1) {
        // Adding a new row at the bottom
        var pm = grid.option("pageModel");
        grid.option("pageModel", { type: 'local', curPage: 1, rPP: pm.rPP, rPPOptions: pm.rPPOptions });
        var rowIndx = grid.addRow({
            newRow: newRowData,
            track: true,
            history: false,
            checkEditable: false,
            refresh: true
        });
        console.log("New row added: Bottom");
        grid.goToPage({ rowIndx: rowIndx });
        grid.editFirstCellInRow({ rowIndx: rowIndx });
    } else {
        // Adding a new row at the top
        var rowIndx = grid.addRow({
            rowIndxPage: 0,
            newRow: newRowData,
            track: true,
            history: false,
            checkEditable: false,
            refresh: true
        });
        console.log("New row added: Top");
        grid.editFirstCellInRow({ rowIndx: rowIndx });
    }


};




Thank you for your help!







10
I am using the following code:

       var grid = $("#grid_jsonp").pqGrid("instance");       
       var matchingRows = grid.pageData().filter(function (row) {
            return row.FASActivity.startsWith("F");
        });

        // Get the row indices of the filtered rows
        var matchingIndices = matchingRows.map(function (row) {
            return grid.getRowIndx({ rowData: row }).rowIndx;
        });
       
        // Use the checkNodes API to check the matching rows
        grid.Checkbox("selected").checkNodes(matchingIndices);

Everything is working correctly expect the last line where the checkNodes function is called.

I am getting the following error message:
Uncaught TypeError: Cannot read properties of undefined (reading 'checkNodes')

I am using v9.x.  Could that be the issue?
Pages: [1] 2 3 ... 10