Skip to content

Misc FAQs

Misc FAQs

Q) Is it possible to load the grid without any data until the first search filter is triggered?

To start with blank grid, set:

$opt["datatype"] = "local";
$opt["loadComplete"] = "function(){ $('#list1').jqGrid('setGridParam',{datatype : 'json'}); }";

where list1 is grid id.

Q) Performance of large tables in PHPGrid?

Performance of loading data in grid consist of 2 parts.

1) Client side: This is usually due to browser rendering capability of large html table, and JS engine that fill html. This can be improved by enabling virtual scrolling of grid. It loads data only when it is required by scrolling.

As per docs, When enabled, the pager elements are disabled and we can use the vertical scrollbar to load data.

$opt["rowNum"] = 50;
$opt["scroll"] = true;

2) Server side: This depends on database optimization factors, such as indexes, usage of 'like' queries etc. Best approach to optimize is to create indexes of your most searchable fields and avoid '%blah%' contains query which never use indexes in mysql. After creating indexes, you can try SELECT queries in phpmyadmin and track loading time. If phpgrid loading time is still slow, drop me a message with your SQL and i'll check the internals.

^ Top

Q) How to use phpgrid with concurrent users?

First solution is to use excel-view (cellEdit) mode. In this way, only the changed cell is submitted to server and not the whole row data. You can refer demos/appearence/excel-view.php for working demo.

Second, If you want application based row level locking in grid:

1) Introduce a new field 'last_modified', make it hidden on grid and editable. It will store the timestamp of row update. 2) Implement an on_update event handler and check if: i) Fetch the edited row db table row, using select query i) Check if posted back 'last_modified' value is different from the one in database against same row id ii) If Yes, You can show phpgrid_error('Already edited') otherwise, go with the update.

Working demo code:

^ Top

Q) How to show some custom success message after bulk update?

Now you can push custom html messages from bulk edit handler. Instead of 'records updated' message, you can have your custom message. This only works with custom bulk-edit.

function update_data($data)
    // If bulk operation is requested, (default otherwise)
    if ($data["params"]["bulk"] == "set-desc")
        $selected_ids = $data["id"]; // e.g. the selected values from grid 5,7,14 (where "id" is field name of first col)
        $str = $data["params"]["data"];

        // here you can code your logic to do bulk processing
        mysql_query("UPDATE invheader SET note = '$str' WHERE id IN ($selected_ids)");
        phpgrid_msg("Download Zip: <a target='_blank' href=''></a>",0);

first param is message, second is autoclose (0/1).

^ Top

Q) Purchasing a license is a one time payment or monthly?

It's one time fees that includes limited period of subscription for updates and technical support. If subscription period is expired, product will keep working as before. However for new updates and technical support you will be required to renew the license.

^ Top

Q) How to pay with Paypal? I'm always redirected to 2Checkout, and I don't have a VISA-card.

When you visit 2checkout page, there is paypal option in last step of payment page. See image.

Paypal Option

^ Top

Q) How to set local timezone in date operations?

This can be set by php default function. For more refer php docs.


Q) How to convert (db stored) UTC time to Local time?

This can be done by using mysql convert_tz function in query.

// you can provide custom SQL query to display data - convert_tz for local time
$g->select_command = "SELECT, CONVERT_TZ(invdate,'+00:00','+5:00') as invdate ,,
                        i.note,, i.closed FROM invheader i
                        INNER JOIN clients c ON c.client_id = i.client_id";

^ Top

Q) How to use multiselect filter?

Step1: Include js/css files

<link rel="stylesheet" href="">
<link rel="stylesheet" href="">
<script src=""></script>
<script src=""></script>

Step2: Set search type for multiselect filter column

// multi-select in search filter
$col["stype"] = "select-multiple";
$col["searchoptions"]["value"] = $str;

Refer: demos/integration/multiselect-filter.php

^ Top

Q) How to load grid based on $_POST data from other page?

The grid is loaded with 2 server calls.

1) load the columns of grid. 2) do an ajax call, to load data of grid.

Now, if you want to pass data from external form, it is available for step1. But not there in 2nd ajax call, as it is not posted. Solution is to put the POST variable in session and use it from session for step2.


if (!empty($_POST["personid"]))
    $_SESSION["personid"] = $_POST["personid"];
$pid = $_SESSION["personid"];

and use $pid in your SQL.

^ Top

Q) How to save data in grid using external form?

You can apply following JS function on click event of external form. You need to change POST data request['column_name'] = 'col_value'; in javascript code, '#list1' is grid id in this example.

function updateData()
    // call ajax to update date in db
    var request = {};
    request['oper'] = 'edit';

    // data to POST
    request['id'] = '1';
    request['company'] = 'test company';
    var grid = jQuery('#list1');

        url: grid.jqGrid('getGridParam','url'),
        dataType: 'html',
        data: request,
        type: 'POST',
        error: function(res, status) {
            jQuery.jgrid.info_dialog(jQuery.jgrid.errors.errcap,'<div class=\"ui-state-error\">'+ res.responseText +'</div>',
        success: function( data ) {
            // reload grid for data changes

^ Top

Q) How to set custom mesage when no records are found?

You can set following JS before echo $out.

jQuery.jgrid.defaults.emptyrecords = "There are no records for your selection";

<?php echo $out?>

^ Top

Updated Thursday, September 26th, 2019