6.0 Archives | phpGrid - PHP Datagrid Create PHP grids in minutes, not hours. Fri, 06 Dec 2024 03:59:28 +0000 en-US hourly 1 CodeProjecthttps://wordpress.org/?v=7.0.3 129966043 Composite Primary Key Support * https://phpgrid.com/example/composite-primary-key-support/ Fri, 18 Oct 2013 00:47:10 +0000 http://phpgrid.com/?p=2663 * An exclusive feature for phpGrid commercial License   In the past, phpGrid supports database SQL that only has a single primary key. If multiple primary keys exist, the recommended workaround was to create an auto-increment column as an alternative single primary key. Though most cases the above solution is sufficient, as the database grows […]

The post Composite Primary Key Support * appeared first on phpGrid - PHP Datagrid.

]]>
* An exclusive feature for phpGrid commercial License

 

In the past, phpGrid supports database SQL that only has a single primary key. If multiple primary keys exist, the recommended workaround was to create an auto-increment column as an alternative single primary key.

Though most cases the above solution is sufficient, as the database grows and its structure evolves, the need to support composite primary key becomes essential, especially in an enterprise environment.

Starting phpGrid 6 (commercial only), you can pass an array of string as primary key in data grid constructor. e.g.

1
array("KEY1", "KEY2", "KEY3"...);

Lots of resources devoted into developing this important feature while making it simple at the same time. In stead of passing a single string variable in the constructor as the primary key, you can now pass an array of strings as the composite primary key. For a single primary key, you can still use a string or an array with a single string value. e.g.

Complete composite primary key example:

1
2
3
4
5
6
7
// 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 orderdetails", array("productCode", "orderNumber"), "orderdetails");
$dg->enable_edit("FORM", "CRUD");
$dg->display();

See Live Example!

For single primary key, you can still pass it as string type, or an array with just a single string element.

1
$dg = new C_DataGrid("SELECT * FROM orders", "orderNumber", "orders");

– OR –

1
$dg = new C_DataGrid("SELECT * FROM orders", array("orderNumber"), "orders");

The post Composite Primary Key Support * appeared first on phpGrid - PHP Datagrid.

]]>
2663
Column Chooser & Sortable Row https://phpgrid.com/example/column-chooser-sortable-row/ Thu, 17 Oct 2013 19:33:57 +0000 http://phpgrid.com/?p=2658 The example below demonstrates column chooser and sortable row features. Click on the column chooser icon in the footbar to reveal the column chooser dialog. To test sortable row, drag a row and move it around. 1234567891011// 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 […]

The post Column Chooser & Sortable Row appeared first on phpGrid - PHP Datagrid.

]]>
The example below demonstrates column chooser and sortable row features. Click on the column chooser icon in the footbar to reveal the column chooser dialog. To test sortable row, drag a row and move it around.

1
2
3
4
5
6
7
8
9
10
11
// 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 products", "productCode", "products");

$dg -> enable_columnchooser(true);
$dg -> set_sortablerow(true);

$dg -> display();

See Live Example!

The post Column Chooser & Sortable Row appeared first on phpGrid - PHP Datagrid.

]]>
2658
Row-level Edit Permission https://phpgrid.com/example/row-level-permission-edit-condtion/ Thu, 17 Oct 2013 18:05:31 +0000 http://phpgrid.com/?p=2650 Using actions column in the earlier example, it’s now possible to specify row-level edit permission for editing using additional javascript. The Javascript used here hides the delete and edit buttons based condition that when status equals to “Shipped”. The example shown is for demo purpose only. It’s NOT 100% secure. Programmer should still check permission […]

The post Row-level Edit Permission appeared first on phpGrid - PHP Datagrid.

]]>
Using actions column in the earlier example, it’s now possible to specify row-level edit permission for editing using additional javascript.

The Javascript used here hides the delete and edit buttons based condition that when status equals to “Shipped”. The example shown is for demo purpose only. It’s NOT 100% secure. Programmer should still check permission on the server side.

For simpler condition without using Javascript, you can consider set_edit_condition() method.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Always include namespace and conf.php on TOP of the script.
use phpCtrl\C_DataGrid;
require_once("/file/path/to/conf.php");  

// note this should not replace database role-based or user-based permissions.
$onGridLoadComplete = <<<ONGRIDLOADCOMPLETE
function(status, rowid)
{
    var ids = jQuery("#orders").jqGrid('getDataIDs');
    for (var i = 0; i < ids.length; i++)
    {
        var rowId = ids[i];
        var rowData = jQuery('#orders').jqGrid ('getRowData', rowId);

        if($("#orders").jqGrid("getCell", rowId, "status") == "Shipped"){
            $("#orders").jqGrid("setCell", rowId, "actions", " zzz ", {"display":"none"}); // not possible to set value for virtual column
        }
    }
}
ONGRIDLOADCOMPLETE
;

$dg = new C_DataGrid("SELECT * FROM orders", "orderNumber", "orders");
$dg->set_col_hidden('comments');

$dg->add_column("actions", array('name'=>'actions',
    'index'=>'actions',
    'width'=>'80',
    'formatter'=>'actions',
    'formatoptions'=>array('keys'=>true)),'Actions');
$dg->set_grid_property(array('onSelectRow'=>'')); // remove onSelect event
$dg->add_event("jqGridLoadComplete", $onGridLoadComplete);
$dg->enable_edit('INLINE');

$dg -> display();

See Live Example!

The post Row-level Edit Permission appeared first on phpGrid - PHP Datagrid.

]]>
2650
enable_autoheight() https://phpgrid.com/documentation/enable_autoheight/ Sat, 12 Oct 2013 18:30:30 +0000 http://phpgrid.com/?p=2626 Parameters: $autoheight: true or false. Default to false. Description: Use this method to set datagrid height as the same as the current window height. Remark: Do not use this method when multiple grids present on a single page Example: 1$dg -> enable_autoheight(true);

The post enable_autoheight() appeared first on phpGrid - PHP Datagrid.

]]>
  • Parameters:
    • $autoheight: true or false. Default to false.
  • Description:
    • Use this method to set datagrid height as the same as the current window height.
  • Remark:
    • Do not use this method when multiple grids present on a single page
  • Example:
  • 1
    $dg -> enable_autoheight(true);

    The post enable_autoheight() appeared first on phpGrid - PHP Datagrid.

    ]]>
    2626
    enable_columnchooser() https://phpgrid.com/documentation/enable_columnchooser/ Sat, 12 Oct 2013 18:26:45 +0000 http://phpgrid.com/?p=2625 Parameters: $enable: true or false Description: Enable column chooser. Remark: The column chooser does not persist. The columns displayed resets whenever grid or the page refreshes. Example: 1$dg -> enable_columnchooser(true);

    The post enable_columnchooser() appeared first on phpGrid - PHP Datagrid.

    ]]>
  • Parameters:
    • $enable: true or false
  • Description:
    • Enable column chooser.
  • Remark:
    • The column chooser does not persist. The columns displayed resets whenever grid or the page refreshes.
  • Example:
  • 1
    $dg -> enable_columnchooser(true);

    The post enable_columnchooser() appeared first on phpGrid - PHP Datagrid.

    ]]>
    2625
    set_sortablerow() https://phpgrid.com/documentation/set_sortablerow/ Sat, 12 Oct 2013 18:17:47 +0000 http://phpgrid.com/?p=2622 Parameters: $sortable: true or false Description: Activate sortable row. Drag and drop row to sort. Remark: The sort does not persist. The sort is lost the grid or the page refreshes. Example: 1$dg -> set_sortablerow(true);

    The post set_sortablerow() appeared first on phpGrid - PHP Datagrid.

    ]]>
  • Parameters:
    • $sortable: true or false
  • Description:
    • Activate sortable row. Drag and drop row to sort.
  • Remark:
    • The sort does not persist. The sort is lost the grid or the page refreshes.
  • Example:
  • 1
    $dg -> set_sortablerow(true);

    The post set_sortablerow() appeared first on phpGrid - PHP Datagrid.

    ]]>
    2622
    THEME global constant https://phpgrid.com/documentation/theme-global-constant/ Sat, 12 Oct 2013 18:11:57 +0000 http://phpgrid.com/?p=2621 Available starting phpGrid version 6, you can set a global constant “THEME” in conf.php to change all of your datagrid themes without calling set_theme() method individually. 12// set a global theme in conf.php (version 6+) define('THEME', 'bootstrap'); Both Bootstrap 3 and 4 (7.4.5+) themes are now supported with ‘bootstrap‘ or ‘bootstrap4‘ The premium themes are […]

    The post THEME global constant appeared first on phpGrid - PHP Datagrid.

    ]]>
    Available starting phpGrid version 6, you can set a global constant “THEME” in conf.php to change all of your datagrid themes without calling set_theme() method individually.

    1
    2
    // set a global theme in conf.php (version 6+)
    define('THEME', 'bootstrap');

    Both Bootstrap 3 and 4 (7.4.5+) themes are now supported with ‘bootstrap‘ or ‘bootstrap4

    The premium themes are currently available in phpGrid commercial licenses.

    The post THEME global constant appeared first on phpGrid - PHP Datagrid.

    ]]>
    2621
    DEBUG global constant https://phpgrid.com/documentation/debug/ Sat, 12 Oct 2013 17:51:36 +0000 http://phpgrid.com/?p=2619 Note: DEBUG global constant is only available starting version 6. For phpGrid version 5.5.5 and lower, see enable_debug() method please. phpGrid version 6 introduces a new global constant named “DEBUG” in conf.php. When set to true, it turns on the debug mode. When not defined, DEBUG value defaults to false. When DEBUG set to true: […]

    The post DEBUG global constant appeared first on phpGrid - PHP Datagrid.

    ]]>
    Note: DEBUG global constant is only available starting version 6. For phpGrid version 5.5.5 and lower, see enable_debug() method please.

    phpGrid version 6 introduces a new global constant named “DEBUG” in conf.php. When set to true, it turns on the debug mode. When not defined, DEBUG value defaults to false.

    When DEBUG set to true:

    • When set to true, it displays phpGrid object as well as the current PHP session information. In addition, AJAX response data are also displayed during CRUD operations. This is helpful debugging information can be used during development.
       
    • It also display the phpGrid version number and associated javascript libraries used.
    1
    2
    // In conf.php
    define('DEBUG', true);

    The post DEBUG global constant appeared first on phpGrid - PHP Datagrid.

    ]]>
    2619
    set_edit_condition() https://phpgrid.com/documentation/set_edit_condition/ Fri, 11 Oct 2013 22:33:05 +0000 http://phpgrid.com/?p=2612 Parameters: $edit_conditoin: An array stores edit permission condition. Description: Set row-level permission condition for editing. Remark: This works for INLINE ONLY by hiding the edit icons using javascript, CSS For that reason, developers should still validate user permission at the database or on the server side. For complex conditions, use add_event and javascript. See row-level […]

    The post set_edit_condition() appeared first on phpGrid - PHP Datagrid.

    ]]>
  • Parameters:
    • $edit_conditoin: An array stores edit permission condition.
  • Description:
    • Set row-level permission condition for editing.
  • Remark:
    • This works for INLINE ONLY by hiding the edit icons using javascript, CSS
    • For that reason, developers should still validate user permission at the database or on the server side.
    • For complex conditions, use add_event and javascript. See row-level edit permission example.
    • Example:
    1
    2
    $dg -> enable_edit('INLINE', 'CRUD');
    $dg -> set_edit_condition(array('status' => '=="Shipped"', '&&', 'customerNumber' => '==114' ));

    The above code snippet generates javascript that validates Status and customerNumber value. If both are true, the edit icon will appear.

    phpGrid_Custom_Edit_Condition_without_using_set_edit_condition

    The post set_edit_condition() appeared first on phpGrid - PHP Datagrid.

    ]]>
    2612
    set_grid_property() https://phpgrid.com/documentation/set_grid_property/ Fri, 11 Oct 2013 21:27:47 +0000 http://phpgrid.com/?p=2606 Parameters: $grid_property: An array represents grid property. The property will add to or overwrite existing PHP data grid properties. List of available grid properties (http://www.trirand.com/jqgridwiki/doku.php?id=wiki:options) Description:  Advanced method that  sets datagrid properties. The parameter must be an array. You must be rather familiar jqGrid API in order to take advantage of this method effectively. In most […]

    The post set_grid_property() appeared first on phpGrid - PHP Datagrid.

    ]]>
  • Parameters:
  • Description:
    •  Advanced method that  sets datagrid properties. The parameter must be an array. You must be rather familiar jqGrid API in order to take advantage of this method effectively. In most cases, you do not need to use this method.
  • Remark:
    • This method is completely difference from set_col_property() method that sets column property, a subset of grid property.
    • This is an advanced method. In most cases, you don’t need to call this method.
  • Example:
  • 1
    2
    3
    $dg -> set_grid_property(array('search'=>true));
    $dg -> set_grid_property(array('direction'=>'rtl'));
    $dg -> set_grid_property(array("altclass" => "alternatie_row_css_class"));

    custo_prop_jsonstr or set_grid_property?

    The difference between cust_prop_jsonstr and set_grid_property is that the later is a function and must take an array as parameter but cust_prop_jsonstr takes string parameter.

    Which one to use?

    The rule of thumb is to use cust_prop_jsonstr when the property is form of string; else use set_grid_property() function. In general, you want to use set_grid_property().

    The post set_grid_property() appeared first on phpGrid - PHP Datagrid.

    ]]>
    2606