Grouping Archives | phpGrid - PHP Datagrid Create PHP grids in minutes, not hours. Fri, 06 Dec 2024 04:01:07 +0000 en-US hourly 1 CodeProjecthttps://wordpress.org/?v=7.0.3 129966043 Drag and Drop Grouping https://phpgrid.com/example/drag-drop-grouping/ Wed, 15 Jun 2016 12:06:07 +0000 http://phpgrid.com/?p=8985 * Please note this feature is only available in commercial licenses.   You can enable drag & drop a column header to group by that column with a single function call to “enable_dnd_grouping()”. Once it’s enabled, you can drag a column header and drop above the grid where it says “Drop column headers here”. 123456789[cc lang="php"] […]

The post Drag and Drop Grouping appeared first on phpGrid - PHP Datagrid.

]]>
phpgrid_dnd_grouping

* Please note this feature is only available in commercial licenses.

 

You can enable drag & drop a column header to group by that column with a single function call to “enable_dnd_grouping()”. Once it’s enabled, you can drag a column header and drop above the grid where it says “Drop column headers here”.

1
2
3
4
5
6
7
8
9
[cc lang="php"]
// Always include namespace and conf.php on TOP of the script.
use phpCtrl\C_DataGrid;
require_once("/file/path/to/conf.php");  

$dg = new C_DataGrid("SELECT * FROM orders", "orderNumber", "orders");
$dg->enable_edit('INLINE');
$dg->enable_dnd_grouping(true);
$dg -> display();

Launch Demo!

The post Drag and Drop Grouping appeared first on phpGrid - PHP Datagrid.

]]>
8985
Math (e.g. Sum, Avg, Count) Operation https://phpgrid.com/example/math-e-g-sum-avg-count-operation/ Tue, 10 Mar 2015 13:14:06 +0000 http://phpgrid.com/?p=3574 It’s possible to perform math operation on numeric columns with a little bit help from Javascript and “jqGridLoadComplete” event handler. It’s important to set “footerrow” to true first. PHP 1$dg->set_grid_property(array("footerrow"=>true)); Javascript: 12var colSum = $('#customers').jqGrid('getCol', 'creditLimit', false, 'sum'); // other options are: avg, count $('#customers').jqGrid('footerData', 'set', { state: 'Total:', 'creditLimit': colSum }); The supported math […]

The post Math (e.g. Sum, Avg, Count) Operation appeared first on phpGrid - PHP Datagrid.

]]>
Math Operation
Math Operation
It’s possible to perform math operation on numeric columns with a little bit help from Javascript and “jqGridLoadComplete” event handler.

It’s important to set “footerrow” to true first.

PHP

1
$dg->set_grid_property(array("footerrow"=>true));

Javascript:

1
2
var colSum = $('#customers').jqGrid('getCol', 'creditLimit', false, 'sum'); // other options are: avg, count
$('#customers').jqGrid('footerData', 'set', { state: 'Total:', 'creditLimit': colSum });

The supported math operations are:

  • sum
  • count

By using sum and count, one can also obtain the avg using sum divided by count.

Complete Code Sample:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Always include namespace and conf.php on TOP of the script.
use phpCtrl\C_DataGrid;
require_once("/path/to/conf.php");  

$dg = new C_DataGrid('SELECT customerName, city, state, creditLimit FROM customers', 'customerName', 'customers');
$dg->set_grid_property(array("footerrow"=>true));
$loadComplete = <<<LOADCOMPLETE
function ()
{
    var colSum = $('#customers').jqGrid('getCol', 'creditLimit', false, 'sum');
    var reccount = jQuery("#customers").jqGrid('getGridParam', 'reccount');
    var avg = Math.round(colSum/reccount * 100/100);
   
    $('#customers').jqGrid('footerData', 'set', { state: 'Total:', 'creditLimit': colSum });
}
LOADCOMPLETE
;
$dg->add_event("jqGridLoadComplete", $loadComplete);
$dg -> display();

See Live Example!

The post Math (e.g. Sum, Avg, Count) Operation appeared first on phpGrid - PHP Datagrid.

]]>
3574
Header Grouping https://phpgrid.com/example/header-grouping/ Sat, 14 Feb 2015 09:49:02 +0000 http://phpgrid.com/?p=3417 Header grouping adds additional columns above the datagrid header rows, so that columns below appears in a group. Typical implementation looks like the screenshot below. Use set_grid_method and set groupHeaders property. numberOfColumns determines number of column to span starting from startColumnName. 123456789101112131415161718// Always include namespace and conf.php on TOP of the script. use phpCtrl\C_DataGrid; require_once("/file/path/to/conf.php"); […]

The post Header Grouping appeared first on phpGrid - PHP Datagrid.

]]>
Header grouping adds additional columns above the datagrid header rows, so that columns below appears in a group. Typical implementation looks like the screenshot below.

header-grouping

Use set_grid_method and set groupHeaders property. numberOfColumns determines number of column to span starting from startColumnName.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Always include namespace and conf.php on TOP of the script.
use phpCtrl\C_DataGrid;
require_once("/file/path/to/conf.php");  

$dg = new C_DataGrid("SELECT * FROM payments", "customerNumber", "orders");

$dg->set_col_width("customerNumber", 30);
$dg->set_col_width("checkNumber",50);
$dg->set_col_width("amount",50);

$dg->set_grid_method('setGroupHeaders', array(
                                array('useColSpanStyle'=>true),
                                'groupHeaders'=>array(
                                        array('startColumnName'=>'customerNumber',
                                              'numberOfColumns'=>2,
                                              'titleText'=>'Numbers Header') )));

$dg -> display();

See Live Example!

The post Header Grouping appeared first on phpGrid - PHP Datagrid.

]]>
3417
Column Methods https://phpgrid.com/example/column-methods/ Sat, 20 Apr 2013 22:34:45 +0000 http://phpgrid.com/?p=2453 Version 5.5.5 introduced set_grid_method() method. You can use this method to call any jqGrid javascript method that can perform actions on the grid as a whole. However, it’s not possible to manipulate the grid on a row or cell level using set_grid_method. The example below demonstrates set_grid_method to grouping header by calling the jqGrid “setGroupHeader” […]

The post Column Methods appeared first on phpGrid - PHP Datagrid.

]]>
Version 5.5.5 introduced set_grid_method() method. You can use this method to call any jqGrid javascript method that can perform actions on the grid as a whole. However, it’s not possible to manipulate the grid on a row or cell level using set_grid_method.

The example below demonstrates set_grid_method to grouping header by calling the jqGrid “setGroupHeader” method.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use phpCtrl\C_DataGrid;
require_once("/file/path/to/conf.php");  

$dg = new C_DataGrid("SELECT * FROM payments", "customerNumber", "orders");

$dg->set_col_width("customerNumber", 30);
$dg->set_col_width("checkNumber",50);
$dg->set_col_width("amount",50);

$dg->set_grid_method('setGroupHeaders',
                        array(
                            array('useColSpanStyle'=>true),
                            'groupHeaders'=>array(
                            array('startColumnName'=>'customerNumber',
                            'numberOfColumns'=>2,
                            'titleText'=>'Numbers Header')
                        )));

$dg->display();

See Live Example!

The post Column Methods appeared first on phpGrid - PHP Datagrid.

]]>
2453
Column Grouping with Summary * https://phpgrid.com/example/column-grouping-with-summary/ Thu, 10 Feb 2011 02:11:02 +0000 http://phpgrid.com/?p=1124 * Please note this feature is only available in paid versions.     phpGrid can group data by columns. Simply define a column name on which grouping occur using method set_group_properties(). In addition to define grouping column, set summary field using method set_group_summary() by passing the column name and summary type, which can be sum, […]

The post Column Grouping with Summary * appeared first on phpGrid - PHP Datagrid.

]]>
* Please note this feature is only available in paid versions.

 

Group Summary

 

phpGrid can group data by columns. Simply define a column name on which grouping occur using method set_group_properties().

In addition to define grouping column, set summary field using method set_group_summary() by passing the column name and summary type, which can be sum, count, avg, min, or max.

 

1
2
3
4
5
6
7
8
9
10
use phpCtrl\C_DataGrid;
require_once("/file/path/to/conf.php");  

$dg = new C_DataGrid("SELECT * FROM payments", "customerNumber", "payments");

$dg->set_group_properties('customerNumber');
$dg->set_group_summary('amount','sum');
$dg->set_group_summary('checkNumber','count');

$dg -> display();

 

See Live Example!

The post Column Grouping with Summary * appeared first on phpGrid - PHP Datagrid.

]]>
1124