4.4 Archives | phpGrid - PHP Datagrid Create PHP grids in minutes, not hours. Fri, 06 Dec 2024 04:04:17 +0000 en-US hourly 1 CodeProjecthttps://wordpress.org/?v=7.0.3 129966043 Conditional Format * https://phpgrid.com/example/conditional-format-2/ Sat, 14 Jan 2012 20:51:16 +0000 http://phpgrid.com/?p=1898 * Please note this feature is not available in Lite and Basic versions.     Conditional formatting example using set_conditional_format() method. 12345678910111213141516171819// 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 * FROM orders", "orderNumber", "orders"); //Format a cell based on the specified condition$dg->set_conditional_format("orderNumber","CELL",array(     […]

The post Conditional Format * appeared first on phpGrid - PHP Datagrid.

]]>
* Please note this feature is not available in Lite and Basic versions.

 

conditional_format_ss

 

Conditional formatting example using set_conditional_format() method.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// 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 * FROM orders", "orderNumber", "orders");

//Format a cell based on the specified condition
$dg->set_conditional_format("orderNumber","CELL",array(
    "condition"=>"eq","value"=>"10107","css"=> array("color"=>"#ffffff","background-color"=>"green")));

$dg->set_conditional_format("customerNumber","CELL",array(
    "condition"=>"eq","value"=>"141","css"=> array("color"=>"red","background-color"=>"#DCDCDC")));

// Format a row based on the specified condition
$dg->set_conditional_format("comments","ROW",array(
    "condition"=>"cn","value"=>"request","css"=> array("color"=>"white","background-color"=>"#4297D7")));    
                     
$dg->set_multiselect(true);
$dg -> display();

See Live Example!

Note:
For even more complex conditions, please refer to row level permission example by using set_grid_property() and add_event() method.

The post Conditional Format * appeared first on phpGrid - PHP Datagrid.

]]>
1898
Horizontal Scroll https://phpgrid.com/example/horizontal-scroll/ Sat, 14 Jan 2012 20:13:25 +0000 http://phpgrid.com/?p=1882 Set parameter $shrinkToFit in set_dimension() to false to enable horizontal scroll when the container width is less than the grid width. The scroll bar will not show when the grid width is equal or less than the container width. 123456789101112131415161718192021222324// Always include namespace and conf.php on TOP of the script. use phpCtrl\C_DataGrid; require_once("/file/path/to/conf.php");   $dg […]

The post Horizontal Scroll appeared first on phpGrid - PHP Datagrid.

]]>
Set parameter $shrinkToFit in set_dimension() to false to enable horizontal scroll when the container width is less than the grid width. The scroll bar will not show when the grid width is equal or less than the container width.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// 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");
 // change column titles
$dg -> set_col_title("orderNumber", "Order No.");
$dg -> set_col_title("orderDate", "Order Date");
$dg -> set_col_title("shippedDate", "Shipped Date");
$dg -> set_col_title("customerNumber",  "Customer No.");
// hide a column
$dg -> set_col_hidden("requiredDate");
// change default caption
$dg -> set_caption("Orders List");
// set export type
$dg -> enable_export('EXCEL');
 // enable integrated search
$dg -> enable_search(true);
// set height and weight of datagrid
$dg -> set_dimension(800, 600, false);
// increase pagination size to 40 from default 20
$dg -> set_pagesize(40);

$dg -> display();

See Live Example!

The post Horizontal Scroll appeared first on phpGrid - PHP Datagrid.

]]>
1882
Create Excel-Like, Responsive Grid https://phpgrid.com/example/grid-auto-width/ Sat, 14 Jan 2012 20:10:24 +0000 http://phpgrid.com/?p=1877 Expand to Current Window Width Use enable_autowidth() and enable_autoheight() to set datagrid responsive with the page dimension to fill the entire screen, similar to Excel spreadsheet. 12345678// 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', 'CRUD'); $dg->enable_autowidth(true)->enable_autoheight(true);$dg->display(); Expand to […]

The post Create Excel-Like, Responsive Grid appeared first on phpGrid - PHP Datagrid.

]]>
Expand to Current Window Width

Use enable_autowidth() and enable_autoheight() to set datagrid responsive with the page dimension to fill the entire screen, similar to Excel spreadsheet.

1
2
3
4
5
6
7
8
// 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', 'CRUD');
$dg->enable_autowidth(true)->enable_autoheight(true);
$dg->display();

Expand to Outer Container Width

By default, auto width function expands datagrid to fit the current window width. When the grid is insider another container, you need to add call setGridWidth() to adjust the width after the grid has been loaded.

1
2
3
$dg->before_script_end .= 'setTimeout(function(){$(window).bind("resize", function() {
        phpGrid_orders.setGridWidth($("#mydiv").width());
    }).trigger("resize");}, 0)'
;

Completely Hide the Horizontal Scrollbar

Add the following CSS to completely hide the horizontal scrollbar of the parent container. In this case, its id is “mydiv”.

1
2
3
4
5
<style>
#mydiv {
    overflow-x: hidden;
}
</style>

Important:

  • “mydiv” is the id of parent DIV in which contains your grid.
  • “phpGrid_orders” is “phpGrid_” + your datagrid table name.

Hint:
Call enable_kb_nav() method to move between rows using only keyboard.

See Live Example! (Try to resize the window)

The post Create Excel-Like, Responsive Grid appeared first on phpGrid - PHP Datagrid.

]]>
1877
Conditional Value * https://phpgrid.com/example/conditional-value/ Sat, 14 Jan 2012 20:08:01 +0000 http://phpgrid.com/?p=1873 * Please note this feature is not available in Lite and Basic versions. Conditional Value is similar to conditional format (see set_conditional_format) but with simpler set of features. Use set_conditional_value() to dynamically display a value when specific condition is met. The conditional value can be text, HTML, or even CSS style. You can use conditional […]

The post Conditional Value * appeared first on phpGrid - PHP Datagrid.

]]>
* Please note this feature is not available in Lite and Basic versions.

Conditional Value is similar to conditional format (see set_conditional_format) but with simpler set of features. Use set_conditional_value() to dynamically display a value when specific condition is met. The conditional value can be text, HTML, or even CSS style.

You can use conditional value with data bar in the same grid.

1
2
3
4
5
6
7
8
.tstyle
{
display:block;background-image:none;margin-right:-2px;margin-left:-2px;height:14px;padding:5px;background-color:green;color:navy;font-weight:bold
}
.fstyle
{
display:block;background-image:none;margin-right:-2px;margin-left:-2px;height:14px;padding:5px;background-color:yellow;color:navy
}

PHP Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// 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 * FROM joborders", "jobNumber", "joborders");
$dg -> set_col_title("jobNumber", "Job Number");
$dg -> set_col_title("jobDescription", "Description");
$dg -> set_col_title("status", "Status");              
$dg -> set_col_title("percentComplete", "Progress (%)");
$dg -> set_col_title("isClosed", "Closed");
 
$dg->set_conditional_value("isClosed", "==1", array(
    "TCellValue"=>"<img src='SampleImages/checked.gif' />",
    "FCellValue"=>"<img src='SampleImages/unchecked.gif' />"));
 
$dg->set_conditional_value("status", "=='Complete'", array(
    "TCellStyle"=>"tstyle",
    "FCellStyle"=>"fstyle"));
 
$dg->enable_edit('INLINE', 'CRUD');
 
$dg->set_multiselect(true);
$dg -> set_databar("percentComplete","red");
$dg -> display();

See Live Example!

Note:
For even more complex conditions, please refer to row level permission example by using set_grid_property() and add_event() method.

The post Conditional Value * appeared first on phpGrid - PHP Datagrid.

]]>
1873
In-cell Data Bar * https://phpgrid.com/example/in-cell-data-bar/ Sat, 14 Jan 2012 20:04:14 +0000 http://phpgrid.com/?p=1870 Bar chart is a great way to visualize numeric data. phpGrid now supports bar chart natively without 3rd party plugin using set_databar() method. You can have multiple data bar in a datagrid. For complex data visualization, we recommend PHP Chart. Please visit PHP Chart for live demo. 123456789101112$dg = new C_DataGrid("SELECT * FROM joborders", "jobNumber", […]

The post In-cell Data Bar * appeared first on phpGrid - PHP Datagrid.

]]>
databar_ss

Bar chart is a great way to visualize numeric data. phpGrid now supports bar chart natively without 3rd party plugin using set_databar() method. You can have multiple data bar in a datagrid.

For complex data visualization, we recommend PHP Chart. Please visit PHP Chart for live demo.

1
2
3
4
5
6
7
8
9
10
11
12
$dg = new C_DataGrid("SELECT * FROM joborders", "jobNumber", "joborders");
$dg -> set_col_title("jobNumber", "Job Number");
$dg -> set_col_title("jobDescription", "Description");
$dg -> set_col_title("status", "Status");              
$dg -> set_col_title("percentComplete", "Progress (%)");
$dg -> set_col_title("isClosed", "Closed");
 
$dg -> set_databar("percentComplete","blue");
$dg -> set_databar("jobNumber","blue");
$dg -> enable_edit("INLINE", "CRUD");
 
$dg -> display();

See Live Example!

The post In-cell Data Bar * appeared first on phpGrid - PHP Datagrid.

]]>
1870
setCallBack https://phpgrid.com/documentation/setcallback/ Sat, 14 Jan 2012 19:57:21 +0000 http://phpgrid.com/?p=1867 Parameters: $callback_str: callback string Description: Used for pass setting between 3rd party system and phpGrid using AJAX callback. Read the comments in file callbackstr.php for usage

The post setCallBack appeared first on phpGrid - PHP Datagrid.

]]>
  • Parameters:
    • $callback_str: callback string
  • Description:
    • Used for pass setting between 3rd party system and phpGrid using AJAX callback. Read the comments in file callbackstr.php for usage

The post setCallBack appeared first on phpGrid - PHP Datagrid.

]]>
1867
set_form_dimension() https://phpgrid.com/documentation/set_form_dimension/ Sat, 14 Jan 2012 19:54:18 +0000 http://phpgrid.com/?p=1865 Parameters: $f_width: form width. The default value is ‘400px’ $f_height: form height. The default is -1 so it is automatically adjusted to number of rows. Description: Set edit FORM width and height during edit. Remark: The default $f_height value is -1 (negative one) so it is automatically adjusted to number of rows. The function only can apply […]

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

]]>
  • Parameters:
    • $f_width: form width. The default value is ‘400px’
    • $f_height: form height. The default is -1 so it is automatically adjusted to number of rows.
  • Description:
    • Set edit FORM width and height during edit.
  • Remark:
    • The default $f_height value is -1 (negative one) so it is automatically adjusted to number of rows.
    • The function only can apply to non-bootstrap themes such as ‘aristo’ or ‘cobalt’. For Bootstrap themes, it has no effect as the layout is managed by the Bootstrap framework.
  • Example:
  • 1
    $dg->set_form_dimension('500px');
    The function only can apply to non-bootstrap themes such as ‘aristo’ or ‘cobalt’. For Bootstrap themes, it has no effect as the layout is managed by the Bootstrap framework.
    X

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

    ]]>
    1865
    enable_kb_nav() – beta https://phpgrid.com/documentation/enable_kb_nav-beta/ Sat, 14 Jan 2012 19:47:57 +0000 http://phpgrid.com/?p=1860 Parameters: $is_enabled: true or false Description: Enable navigation by keyboard using up and down arrow keys. Remark: This is a beta feature currently. Not recommended using it in production. Example: 1$dg->enable_kb_nav(true);

    The post enable_kb_nav() – beta appeared first on phpGrid - PHP Datagrid.

    ]]>
  • Parameters:
    • $is_enabled: true or false
  • Description:
    • Enable navigation by keyboard using up and down arrow keys.
  • Remark:
    • This is a beta feature currently. Not recommended using it in production.
  • Example:
  • 1
    $dg->enable_kb_nav(true);

    The post enable_kb_nav() – beta appeared first on phpGrid - PHP Datagrid.

    ]]>
    1860
    get_display() https://phpgrid.com/documentation/get_display/ Sat, 14 Jan 2012 19:35:43 +0000 http://phpgrid.com/?p=1849 Parameters: $add_script_includeonce: true or false. Whether or not to include script header. Description: It returns the grid body with options to include script header. It is useful for MVC framework integration such as Joomla! and Drupal. Remark: The get_display() function should be called AFTER display() is called so that the grid body and header is saved […]

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

    ]]>
  • Parameters:
    • $add_script_includeonce: true or false. Whether or not to include script header.
  • Description:
    • It returns the grid body with options to include script header. It is useful for MVC framework integration such as Joomla! and Drupal.
  • Remark:
    • The get_display() function should be called AFTER display() is called so that the grid body and header is saved to an internal output buffer that can be later retrieved by get_display().
  • Example:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    $dg = new C_DataGrid("SELECT * FROM orders", "orderNumber", "orders");
    $dg -> display(false);  // do not render display
    $grid = $dg -> get_display(false);  // do not include required javascript libraries until later with with display_script_includeonce method.

    // other page content goes here
    /* ........................... */

    $dg -> display_script_includeonce();
    echo $grid;

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

    ]]>
    1849
    enable_autowidth() https://phpgrid.com/documentation/enable_autowidth/ Sat, 14 Jan 2012 19:16:40 +0000 http://phpgrid.com/?p=1843 Parameters: $autowidth: true or false Description: Use this method to set datagrid width as the same as the current window width. Automatically resizes based on window width (verison 6+) Example: 1$dg -> enable_autowidth(true); Set auto width to expand its container (e.g. body), then followed by setting static width for horizontal scroll. Works the best when the […]

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

    ]]>
  • Parameters:
    • $autowidth: true or false
  • Description:
    • Use this method to set datagrid width as the same as the current window width.
    • Automatically resizes based on window width (verison 6+)
  • Example:
  • 1
    $dg -> enable_autowidth(true);

    Set auto width to expand its container (e.g. body), then followed by setting static width for horizontal scroll. Works the best when the grid has many columns but in a small container.

    1
    2
    $dg->enable_autowidth(true);
    $dg->set_dimension('2000', 'auto', false);

    Optional

    Sometimes the browser overcalculates the document width and displays the scrollbar. You can hide it using the following CSS.

    1
    2
    3
    body{
      overflow:hidden;
    }

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

    ]]>
    1843