phpGrid 4.3 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 Display Non-English Characters https://phpgrid.com/example/display-foreign-language-characters/ Wed, 30 Mar 2011 01:30:59 +0000 http://phpgrid.com/?p=1323 If database is created in charset other than default charset, e.g. “latin1″, some characters may be displayed as “?” in the grid. To properly display non-English characters, such as Spanish, Fresh, or Chinese, in MySQL, PostgreSQL, and Oracle you can define the character set value in ‘DB_CHARSET’ variable in conf.php. In conf.php, set the DB_CHARSET […]

The post Display Non-English Characters appeared first on phpGrid - PHP Datagrid.

]]>
If database is created in charset other than default charset, e.g. “latin1″, some characters may be displayed as “?” in the grid. To properly display non-English characters, such as Spanish, Fresh, or Chinese, in MySQL, PostgreSQL, and Oracle you can define the character set value in ‘DB_CHARSET’ variable in conf.php.

In conf.php, set the DB_CHARSET to the corresponding charsets in your database.

version 6+ (with “PHPGRID_” prefix):

1
2
3
4
5
6
define('PHPGRID_DB_HOSTNAME','hostname'); // database host name
define('PHPGRID_DB_USERNAME', 'username'); // database user name
define('PHPGRID_DB_PASSWORD', 'password'); // database password
define('PHPGRID_DB_NAME', 'sampledb'); // database name
define('PHPGRID_DB_TYPE', 'mysql'); // database type
define('PHPGRID_DB_CHARSET','utf8'); // OPTIONAL. Leave blank to use the default charset

version 5.5.x and below:

1
2
3
4
5
6
define('DB_HOSTNAME','hostname'); // database host name
define('DB_USERNAME', 'username'); // database user name
define('DB_PASSWORD', 'password'); // database password
define('DB_NAME', 'sampledb'); // database name
define('DB_TYPE', 'mysql'); // database type
define('DB_CHARSET','utf8'); // OPTIONAL. Leave blank to use the default charset

Add the Meta element to the HTML head node and set character encoding to UTF-8. Note it’s important that the actual file must also be saved as UTF-8 encoding.

1
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

 

Dealing with Special Characters in SQL Server with Non-English Collation

It is slightly more complicated when using SQL Server collation other than the default English-language (US) “SQL_Latin1_General“, you may have trouble display those non-English characters such as “Löi, cé”.

The methods below is also available on KB. It demonstrate how to display Chinese (BIG5) characters from SQL Server.

In data.php, near line 213 change the following from

1
$data[] = $row[$col_name];

to

1
$data[] = iconv("BIG5", "UTF-8", $row[$col_name]);

– OR –

1
$data[] = mb_convert_encoding($row[$col_name], "UTF-8", "BIG5");

Also in the same file, below comment
“// ******************* execute query finally *****************”

Add the following line

1
$SQL = iconv("UTF-8","BIG5",$SQL);

 

Foreign Characters in PDF export

To export Chinese or other foreign characters, see KB: PDF can not display Chinese character
 

See Live Example!

The post Display Non-English Characters appeared first on phpGrid - PHP Datagrid.

]]>
1323
Reference to Multiple Databases * https://phpgrid.com/example/multiple-databases-support/ Tue, 29 Mar 2011 18:23:02 +0000 http://phpgrid.com/?p=1316 * Please note this feature is only available in paid versions. phpGrid nows supports data source from more than one database on a single page. Simply use the 4th parameter in constructor (C_DataGrid) to overwrite the initial database settings in conf.php. In the following example, grid A binds a table from one database, while grid […]

The post Reference to Multiple Databases * appeared first on phpGrid - PHP Datagrid.

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

phpGrid nows supports data source from more than one database on a single page. Simply use the 4th parameter in constructor (C_DataGrid) to overwrite the initial database settings in conf.php.

In the following example, grid A binds a table from one database, while grid B binds another table from a completely different database, all on the same page.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$gridA = new C_DataGrid("SELECT * FROM orders", "orderNumber", "orders");
$gridA->enable_edit("INLINE","CRUD");
$gridA -> display();

// overwrite database settings with another database.
$gridB = new C_DataGrid("SELECT * FROM names", "id", "names",
                        array("hostname"=>"localhost",
                            "username"=>"USER2",
                            "password"=>"PASSWORD",
                            "dbname"=>"utf8db",
                            "dbtype"=>"mysql",
                            "dbcharset"=>"utf8"));

$gridB->enable_edit("INLINE","CRUD");
$gridB -> display();

The post Reference to Multiple Databases * appeared first on phpGrid - PHP Datagrid.

]]>
1316
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
set_conditional_format() * https://phpgrid.com/documentation/set_conditional_format/ Tue, 29 Mar 2011 05:16:36 +0000 http://phpgrid.com/?p=1290 * Please note this feature is not available in Lite and Basic versions. Parameters: $col_name: column name $type: CELL or ROW $formatoptions: array that stores condition and css style options Description: Format a cell based on the specified condition. CELL formats the a single cell. ROW formats the entire row.   $formatoption is the most […]

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

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

  • Parameters:
    • $col_name: column name
    • $type: CELL or ROW
    • $formatoptions: array that stores condition and css style options
  • Description:
    • Format a cell based on the specified condition. CELL formats the a single cell. ROW formats the entire row.
       

      $formatoption is the most important parameter which itself is an array contains three elements:

      • condition,
      • value,
      • css.
       

      The elements are described in details as the following:

      The first parameter, condition, has the following available value.

      eq: Equals
      ne: Not Equals
      lt: Less than
      le: Less than or Equal
      gt: Greater than
      ge: Greater than or Equal
      cn: Contains
      nc: Does not Contain
      bw: Begins With
      bn: Not Begins With
      ew: Ends With
      en: Not Ends With

      The second parameter, value, is the comparing value in the right operand.

      css parameter in $formattoptions is an array collection that contains css style element for current cell or row.

  • Example:
1
2
3
4
5
6
7
8
9
10
11
12
13
//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")));

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

]]>
1290
set_locale() https://phpgrid.com/documentation/set_locale0/ Tue, 29 Mar 2011 05:11:11 +0000 http://phpgrid.com/?p=1287 Parameters: $locale: language locale. List of values are: bg, cat, cn, cs, de, dk, el, en, fa, fi, fr, he, hu, is, it, ja, nl, no, pl, pt, ro, ru, sp, sv, tr, ua. Description: If you are using phpGrid in a language rather English, you may want the datagrid to display appropriate system text […]

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

]]>
  • Parameters:
    • $locale: language locale. List of values are: bg, cat, cn, cs, de, dk, el, en, fa, fi, fr, he, hu, is, it, ja, nl, no, pl, pt, ro, ru, sp, sv, tr, ua.
  • Description:
    • 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.
  • Example:
  • 1
    $dg -> set_locale("fr"); // French locale

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

    ]]>
    1287
    enable_advanced_search() https://phpgrid.com/documentation/enable_advanced_search/ Tue, 29 Mar 2011 05:08:28 +0000 http://phpgrid.com/?p=1285 Parameters: $has_adsearch: boolean value. Set true to enable advanced search Description: Advanced search is different from the integrated search (see enable_search()). It can apply mulitple conditionals to a single field during advanced search. It is super flexible and easy to use. Example: 1$dg -> enable_advanced_search(true);

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

    ]]>
  • Parameters:
    • $has_adsearch: boolean value. Set true to enable advanced search
  • Description:
    • Advanced search is different from the integrated search (see enable_search()). It can apply mulitple conditionals to a single field during advanced search. It is super flexible and easy to use.
  • Example:
  • 1
    $dg -> enable_advanced_search(true);
    Built-in Advanced Search
    Built-in Advanced Search

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

    ]]>
    1285
    set_col_align() https://phpgrid.com/documentation/set_col_align/ Tue, 29 Mar 2011 05:05:52 +0000 http://phpgrid.com/?p=1279 Parameters: $col_name: column name $align: alignment direction: “left”, “center”, or “right”. Description: Horizontal alignment of text in a column. The default alignment is left. Example: 1$dg -> set_col_align('amount', 'right');

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

    ]]>
  • Parameters:
    • $col_name: column name
    • $align: alignment direction: “left”, “center”, or “right”.
  • Description:
    • Horizontal alignment of text in a column. The default alignment is left.
  • Example:
  • 1
    $dg -> set_col_align('amount', 'right');

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

    ]]>
    1279