Basic Archives | phpGrid - PHP Datagrid Create PHP grids in minutes, not hours. Fri, 06 Dec 2024 04:20:27 +0000 en-US hourly 1 CodeProjecthttps://wordpress.org/?v=7.0.3 129966043 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
Locale Setting https://phpgrid.com/example/locale-setting/ Tue, 29 Mar 2011 18:19:45 +0000 http://phpgrid.com/?p=1314 If you are using phpGrid in a language rather English, you may want the datagrid to display appropriate system text used by phpGrid such as “Submit”, “Next”, “Page”, “Find” etc. The language locale files are located in js\src\i18n directory.         12345require_once("/file/path/to/conf.php");   $dg = new phpCtrl\C_DataGrid("SELECT * FROM orders", "orderNumber", "orders"); $dg->set_locale('fr'); […]

The post Locale Setting appeared first on phpGrid - PHP Datagrid.

]]>
If you are using phpGrid in a language rather English, you may want the datagrid to display appropriate system text used by phpGrid such as “Submit”, “Next”, “Page”, “Find” etc. The language locale files are located in js\src\i18n directory.

 
 
phpGrid Comprehensive Locale Support
 
 

1
2
3
4
5
require_once("/file/path/to/conf.php");  

$dg = new phpCtrl\C_DataGrid("SELECT * FROM orders", "orderNumber", "orders");
$dg->set_locale('fr');        
$dg -> display();

See Live Example!

The post Locale Setting appeared first on phpGrid - PHP Datagrid.

]]>
1314
Interactive Datagrid Resizing https://phpgrid.com/example/resize-datagrid-with-the-mouse/ Thu, 16 Sep 2010 23:53:12 +0000 http://64.38.236.7/?p=532 When enabled, the small triangle icon is displayed at the right bottom corner of the grid. The php grids can be resized by simply click and drag the icon using mouse. This is more convenient than setting the width and height in the code. 123456789101112131415161718192021222324252627282930313233343536// Always include namespace and conf.php on TOP of the script. […]

The post Interactive Datagrid Resizing appeared first on phpGrid - PHP Datagrid.

]]>
When enabled, the small triangle icon is displayed at the right bottom corner of the grid. The php grids can be resized by simply click and drag the icon using mouse. This is more convenient than setting the width and height in the 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
25
26
27
28
29
30
31
32
33
34
35
36
// 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", "productCode");
$dg ->set_col_title("productCode", "Product Code");
$dg ->set_col_title("productName", "Product Name");
$dg ->set_col_title("productLine", "Product Line");

// display static Url
$dg ->set_col_link("productUrl");                                            

// dynamic url. e.g.http://www.example.com/?productCode=101&foo=bar
$dg -> set_col_dynalink("productCode", "http://www.example.com/", "productCode", '&foo=bar');

// column format
$dg -> set_col_currency("buyPrice");
$dg -> set_col_format("quantityInStock", "integer", array("thousandsSeparator" => ",",
                                                          "defaultValue" => "0"));  
$dg -> set_col_format("MSRP", 'currency', array("prefix" => "$",
                                                "suffix" => '',
                                                "thousandsSeparator" => ",",
                                                "decimalSeparator" => ".",
                                                "decimalPlaces" => '2',
                                                "defaultValue" => '0.00'));

// the above line is equivalent to the following helper function                        
$dg -> set_col_currency("MSRP", "$", '', ",",".", "2", "0.00");                                      

// display image
$dg -> set_col_img("Image");

// enable resize by dragging mouse
$dg -> enable_resize(true);
                                                 
$dg -> display();

See Live Example!

The post Interactive Datagrid Resizing appeared first on phpGrid - PHP Datagrid.

]]>
532
Image Display https://phpgrid.com/example/image-display/ Thu, 16 Sep 2010 23:49:56 +0000 http://64.38.236.7/?p=529 Display image is easy in phpGrid. Simply set the column name in set_col_img(), phpGrid will take care of the rest.   1234567891011121314151617181920212223242526272829303132use phpCtrl\C_DataGrid; require_once("/file/path/to/conf.php");   $dg = new C_DataGrid("select * from products", "productCode", "productCode"); $dg -> set_col_title("productCode", "Product Code"); $dg -> set_col_title("productName", "Product Name"); $dg -> set_col_title("productLine", "Product Line"); // display static Url $dg -> […]

The post Image Display appeared first on phpGrid - PHP Datagrid.

]]>
Display image is easy in phpGrid. Simply set the column name in set_col_img(), phpGrid will take care of the rest.

 

phpGrid Image Display

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
use phpCtrl\C_DataGrid;
require_once("/file/path/to/conf.php");  

$dg = new C_DataGrid("select * from products", "productCode", "productCode");
$dg -> set_col_title("productCode", "Product Code");
$dg -> set_col_title("productName", "Product Name");
$dg -> set_col_title("productLine", "Product Line");

// display static Url
$dg -> set_col_link("productUrl");                                            

// dynamic url. e.g.http://www.example.com/?productCode=101&foo=bar
$dg -> set_col_dynalink("productCode", "http://www.example.com/", "productCode", '&foo=bar');

// column format
$dg -> set_col_currency("buyPrice");
$dg -> set_col_format("quantityInStock", "integer", array("thousandsSeparator" => ",",
                                                          "defaultValue" => "0"));  
$dg -> set_col_format("MSRP", 'currency', array("prefix" => "$",
                                                "suffix" => '',
                                                "thousandsSeparator" => ",",
                                                "decimalSeparator" => ".",
                                                "decimalPlaces" => '2',
                                                "defaultValue" => '0.00'));

// the above line is equivalent to the following helper function                        
$dg -> set_col_currency("MSRP", "$", '', ",",".", "2", "0.00");                                      

// display image
$dg -> set_col_img("Image");
                                                 
$dg -> display();


You can also further adjust image display options such as width, height and border with CSS using set_col_property method. The CSS will only apply the specific column.

1
2
3
<style>
    .image_css img{width: 40pt;border:1px solid black;}
</style>
1
$dg->set_col_property('Image', array("classes"=>'image_css'));

Alternatively, you can also resize images for the entire grid with CSS.

 
See Live Example!

The post Image Display appeared first on phpGrid - PHP Datagrid.

]]>
529
Display Dynamic URL https://phpgrid.com/example/display-dynamic-url/ Thu, 16 Sep 2010 23:42:51 +0000 http://64.38.236.7/?p=522 From example above, we learn that phpGrid can display simple, static URL using set_col_link() method. However, it is often for database driven webpage that URL is dynamically formed based on parameters value. Method set_col_dynalink() is designed specially for this purpose. The following demonstrates passing the column orderNumber as the dynamic value used as part of […]

The post Display Dynamic URL appeared first on phpGrid - PHP Datagrid.

]]>
From example above, we learn that phpGrid can display simple, static URL using set_col_link() method. However, it is often for database driven webpage that URL is dynamically formed based on parameters value. Method set_col_dynalink() is designed specially for this purpose.

The following demonstrates passing the column orderNumber as the dynamic value used as part of the URL.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// 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", "productCode");
$dg -> set_col_title("productCode", "Product Code");
$dg -> set_col_title("productName", "Product Name");
$dg -> set_col_title("productLine", "Product Line");
         
// display static Url
$dg -> set_col_link("productUrl");
                 
// display dynamic url. e.g.http://www.example.com/?productCode=101&foo=bar
$dg -> set_col_dynalink("productCode", "http://www.example.com/", "productCode", '&foo=bar');                                                                  

$dg -> display();

See Live Example!

The post Display Dynamic URL appeared first on phpGrid - PHP Datagrid.

]]>
522
Hyperlink Display https://phpgrid.com/example/display-hyperlink/ Thu, 16 Sep 2010 23:36:07 +0000 http://64.38.236.7/?p=520 You can display the text in column as static hyperlink by calling set_col_link() and passing the column name. Note this method only display static URL stored in database field. To display dynamic URL links based in variables, see the next example on set_col_dynalink() method. Please note we are using Products table in this example. 12345678910111213// […]

The post Hyperlink Display appeared first on phpGrid - PHP Datagrid.

]]>
You can display the text in column as static hyperlink by calling set_col_link() and passing the column name. Note this method only display static URL stored in database field. To display dynamic URL links based in variables, see the next example on set_col_dynalink() method.

Please note we are using Products table in this example.

1
2
3
4
5
6
7
8
9
10
11
12
13
// 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", "productcode");
$dg -> set_col_title("productCode", "Product Code");
$dg -> set_col_title("productName", "Product Name");
$dg -> set_col_title("productLine", "Product Line");

// display static Url
$dg -> set_col_link("productUrl");                                            
                                                                                     
$dg -> display();

See Live Example!

The post Hyperlink Display appeared first on phpGrid - PHP Datagrid.

]]>
520
Datagrid Pagination https://phpgrid.com/example/set-pagination/ Thu, 16 Sep 2010 00:24:36 +0000 http://64.38.236.7/?p=510 By default, the pagination size is 20. It means maximum of 20 records can be displayed in a page. This value can be easily changed with set_pagesize() method. Be aware that pagination is disabled when set_scroll() is set to true. See the next example on set_scroll() for more information. 12345678910111213141516171819202122232425262728293031// Always include namespace and conf.php […]

The post Datagrid Pagination appeared first on phpGrid - PHP Datagrid.

]]>
By default, the pagination size is 20. It means maximum of 20 records can be displayed in a page. This value can be easily changed with set_pagesize() method. Be aware that pagination is disabled when set_scroll() is set to true. See the next example on set_scroll() for more information.

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
// 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);

// increase pagination size to 40 from default 20
$dg -> set_pagesize(40);
 
$dg -> display();

See Live Example!

The post Datagrid Pagination appeared first on phpGrid - PHP Datagrid.

]]>
510
Set Grid Height and Width https://phpgrid.com/example/set-height-and-width/ Thu, 16 Sep 2010 00:22:12 +0000 http://64.38.236.7/?p=507 Use set_dimension() method to specify grid initial height and width. The default height and width is 400 by 300 pixels. In this example, the width is set to 800 pixel, and height is set to 600 pixel. Wait, It looks funny! The grid height is taller than the space used by the number of rows […]

The post Set Grid Height and Width appeared first on phpGrid - PHP Datagrid.

]]>
Use set_dimension() method to specify grid initial height and width. The default height and width is 400 by 300 pixels. In this example, the width is set to 800 pixel, and height is set to 600 pixel.

Wait, It looks funny! The grid height is taller than the space used by the number of rows in a page. To fix this, we can set bigger pagination to accommodate a taller grid. See the next example on pagination.

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
// 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 grid
$dg -> set_dimension(800, 600);
 
$dg -> display();

See Live Example!

The post Set Grid Height and Width appeared first on phpGrid - PHP Datagrid.

]]>
507
Integrated Search https://phpgrid.com/example/integrated-search/ Thu, 16 Sep 2010 00:20:38 +0000 http://64.38.236.7/?p=505 phpGrid includes integrated search. By default, this feature is not enabled. To enable search use enable_search() method with parameter set to true. Once enabled, the integrated search can be toggled with the search button on the footer.     Notice the “status” is automatically rendered as a drop-down in the integrated search(v5.5+). Talking about making […]

The post Integrated Search appeared first on phpGrid - PHP Datagrid.

]]>
phpGrid includes integrated search. By default, this feature is not enabled. To enable search use enable_search() method with parameter set to true. Once enabled, the integrated search can be toggled with the search button on the footer.

 

Integrated Search

 

Notice the “status” is automatically rendered as a drop-down in the integrated search(v5.5+). Talking about making your life easy? :)

To always display the search toolbar, please see Always display integrated search toolbar on KB.

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
// 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_captin("Orders List");

// set export type and edit select type
$dg -> enable_export('EXCEL');
$dg -> enable_edit('FORM', 'CRUD');
$dg -> set_col_edittype('status', 'select', 'Open:Open;Shipped:Shipped;Cancelled:Cancelled;Disputed:Disputed;On Hold:On Hold');

// enable integrated search
$dg -> enable_search(true);
 
$dg -> display();

See Live Example!

It is possible to externalize search command using Javascript. Check out Externalize Search Example.

The post Integrated Search appeared first on phpGrid - PHP Datagrid.

]]>
505
Export Data to Excel, PDF, CSV, and HTML https://phpgrid.com/example/export-datagrid-to-excel-or-html/ Thu, 16 Sep 2010 00:18:41 +0000 http://64.38.236.7/?p=503    phpGrid currently supports export in native Excel format, CSV, PDF, and HTML format. When the export feature is enabled, phpGrid displays an export icon in the footer. Users can export data to Excel in php or any one of the supported file formats Also see enable_export().   If you want to enable users to […]

The post Export Data to Excel, PDF, CSV, and HTML appeared first on phpGrid - PHP Datagrid.

]]>
export_icons

  

phpGrid currently supports export in native Excel format, CSV, PDF, and HTML format. When the export feature is enabled, phpGrid displays an export icon in the footer. Users can export data to Excel in php or any one of the supported file formats Also see enable_export().

 
If you want to enable users to export data from the PHP grids, you should enable this feature. By default, users can export to Microsoft Office Excel, PDF, HTML, or CSV any list of data that appears in a grid. Export to Excel produces native Microsoft Excel .xls file format.
 
Native Excel .xls format is now supported in version 6.7. Previously Excel export is in OpenOffice XML .xml format.
X
Users can export data to Excel in php or any one of the supported file formats by clicking the Export button that appears in the footer. Users can only export data appears in the datagrid. All hidden columns made with set_col_hidden() are not included in the export. It is not recommended to enable export feature when the datagrid contains data such as social security numbers or passwords.
 
When users click Export button, the phpGrid will generate the export file by using data from the database table in Ajax. Data that does not appear on the screen is not exported. If search filter is used, only the filtered results are exported.
 

When the datagrid contains fields that reference to others database tables through lookups, the text will be used in the export rather than the id fields. Please check out the “select” control type in set_col_edittype function.

 
PDF and CSV formats are now supported (Available to Premium Edition) !
 

grid-export

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// 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");
// EXCEL export
$dg->enable_export('PDF');
$dg->display();

$dg2 = new C_DataGrid("select * from customers", "customerNumber", "Customers");
// PDF export
$dg2->enable_export('EXCEL');
$dg2->display();

See Live Demo!

The post Export Data to Excel, PDF, CSV, and HTML appeared first on phpGrid - PHP Datagrid.

]]>
503