At the last time I receive many letters with the request to accelerate release of new versions. First of the all, thanks for your supporting, but I have not many time for this project, really... Development of this project will be continued, but we'll choose another way.
From now I start to publish the Beta versions of PHP DataGrid, so those people, who want to get a new features - could get them through shorter time intervals.
Ok. So, the first beta version of PHP DataGrid 3.2.3 is available for downloading NOW and HERE!
Saturday, December 30, 2006
Friday, December 08, 2006
Some thoughts and ideas...
1. I'm continuing to work persistently (very hard :)) on the next version of PHP DataGrid.
2. Sometimes I think about something more complicated, like PHP Ajax DataGrid. Why not?
3. If you have a public site, that use PHP DataGrid - please, post a link to this site on the forum.
4. Last small bug in version 3.x.x: See forum discussing here.
2. Sometimes I think about something more complicated, like PHP Ajax DataGrid. Why not?
3. If you have a public site, that use PHP DataGrid - please, post a link to this site on the forum.
4. Last small bug in version 3.x.x: See forum discussing here.
Saturday, November 11, 2006
New 3.2.0 version of PHP DataGrid
New 3.2.0 version of PHP DataGrid is available for downloading from now.
This version changes:
- Added:
-- ability to define array of page sizes
-- case sensitivity (filtering mode)
-- ability to define search field to be a dropdown box (filtering mode)
-- ability to add optional column in datagrid by editing SELECT SQL statement
-- new css template (default)
-- ability to define column data to be a link on edit mode page
("linktoview" in setColumnsInViewMode())
- Improved:
-- setModes()
-- css class "default"
-- working with $_REQUEST vars
- Fixed bugs:
-- in filtering mode
-- in tabular layout drawing
-- in columnar layout drawing
-- in paging after search
-- empty table bug
Remember! This is not an update version. If you use old version of PHP DataGrid - you need to reinstall it (see here how you do it).
To download a new version click here.
To see Live Demo click here.
Saturday, October 28, 2006
Some important notes!
PHP DataGrid is still in the development phase, so please...
1. Make sure, that every table in the database you use has a primary key!
2. In "SELECT" SQL statement put this key field at the first place.
3. Don't use in your "SELECT" SQL statement "ORDER BY" option - it's ordered by primary key automaticly.
Small bug in version 3.x.x:
See forum discussing here.
1. Make sure, that every table in the database you use has a primary key!
2. In "SELECT" SQL statement put this key field at the first place.
3. Don't use in your "SELECT" SQL statement "ORDER BY" option - it's ordered by primary key automaticly.
Small bug in version 3.x.x:
See forum discussing here.
New version 3.1.0 of PHP DataGrid
New version 3.1.0 of PHP DataGrid is available for downloading from now.
General features of this version:
-------------------------
- View mode
-- Tabular layout
-- Columnar layout
- Details mode
-- Columnar layout
- Add new mode
- Edit mode
-- Tabular layout
-- Columnar layout
- Delete mode
- Automatic validation
-- Client side
- Columns sorting
- Fields filtering
- Paging
-- current/total pages selector
-- pager
-- page size drop-down box
- Embedded css templates
To download a new version click here.
To see Live Demo click here.
The new version comes in .rar archive that contains following files:
- Datagrid folder
-- datagrid.class.php
-- form.scripts.js
-- calendar.js
-- cal.gif
- Example folder
-- code_example.php
-- database_example(SQL).txt
- lisence.txt
- readme.txt
- documentation.txt
Friday, October 27, 2006
PHP DataGrid v.3.x.x
--------------------------------------------------------------
To download version 3.2.0 click here.
This version changes:
- Added
-- ability to define array of page sizes
-- case sensitivity (filtering mode)
-- ability to define search field to be a dropdown box (filtering mode)
-- ability to add optional column in datagrid by editing SELECT SQL statement
-- new css template (default)
-- ability to define column data to be a link on edit mode page
("linktoview" in setColumnsInViewMode())
- Improved:
-- setModes()
-- css class "default"
-- working with $_REQUEST vars
- Fixed bugs:
-- in filtering mode
-- in tabular layout drawing
-- in columnar layout drawing
-- in paging after search
-- empty table bug
To download version 3.1.0 click here.
--------------------------------------------------------------
PHP DataGrid documentation for version 3.x.x
--------------------------------------------------------------
1. System Requirements
------------------------------
PHP DataGrid is operating system independent. You get it works
on both Linux and Windows. You need following components are
installed:
- PHP 4.0 script engine or later
- Apache 1.3 or above
- mySQL 3.23 or above
2. Lisencing
------------------------------
GNU GPL. See the Lisence.txt file.
3. Installation
------------------------------
<? require_once($PHP_DATAGRID_FOLDER_PATH."/datagrid.class.php") ?>
Where $PHP_DATAGRID_FOLDER_PATH - is a path to the folder
named "datagrid" stored on your server.
3. General Features
------------------------------
- CSS emb.templates
- Column sorting
- Filtering
- Pagging
- Automatic validation
-- Client side
- View mode
-- Tabular layout
-- Columnar layout
- Details mode
-- Columnar layout
- Add new mode
- Edit mode
-- Tabular layout
-- Columnar layout
- Delete mode
To see example of code click here.
To download version 3.2.0 click here.
To download version 3.1.0 click here.
--------------------------------------------------------------
Thursday, October 26, 2006
Code example for PHP DataGrid v.3.x.x
<?
########################################
## Creating & Calling
## --------------------------------------------------------
require_once('datagrid/datagrid.class.php');
##
## *** creating variables that we need for database connection
$DB_USER='phpbuilder_dgrid'; // usually like this: prefix_name
$DB_PASS='12345'; // must be already enscrypted
$DB_HOST='db5.awardspace.com'; // often localhost
$DB_NAME='phpbuilder_dgrid'; // usually like this: prefix_name
ob_start();
$db_conn = mysql_connect($DB_HOST,$DB_USER,$DB_PASS);
mysql_select_db($DB_NAME,$db_conn);
## *** put primary key on the first place
$sql=" SELECT "
."tblCountries.CountryID, "
."tblRegions.Name as Region, "
."tblCountries.Name, "
."tblCountries.Description, "
."tblCountries.Population, "
."tblCountries.PictureURL, "
."tblDemocracy.description as is_democracy "
."FROM tblCountries INNER JOIN tblRegions ON tblCountries.RegionID=tblRegions.RegionID "
."LEFT OUTER JOIN tblDemocracy ON tblCountries.is_democracy=tblDemocracy.did ";
$dgrid = new DataGrid();
$dgrid->dataSource($db_conn, $sql);
##
## General Settings
## --------------------------------------------------------
## *** set unique prefix
$u_prefix = "_abc";
$dgrid->setUniqueNames($u_prefix);
## *** set direction: "ltr" or "rtr"
$direction = "ltr";
$dgrid->setDirection($direction);
## *** set layouts: 0 - tabular(horizontal) - default, 1 - columnar(vertical)
$layouts = array("view"=>0, "edit"=>1, "filter"=>1);
$dgrid->setLayouts($layouts);
## *** set other modes
$modes = array(
"add"=>array("view"=>true, "edit"=>false),
"edit"=>array("view"=>true, "edit"=>true, "byfield"=>""),
"cancel"=>array("allow"=>true,"view"=>true, "edit"=>true),
"details"=>array("view"=>true, "edit"=>false),
"delete"=>array("view"=>true, "edit"=>true)
);
$dgrid->setModes($modes);
## *** set nowrap attributes for all columns
$wrap = "nowrap";
$dgrid->setColumnsNoWrap($wrap);
## *** set CSS class for datagrid: "default" or "like adwords" or "salomon"
$css_class = "default";
$dgrid->setCssClass($css_class);
##
## Sorting & Paging Settings:
## ---------
## *** set sorting option: true(default) or false
$s_option = true;
$dgrid->allowSorting($s_option);
## *** set paging option: true(default) or false
$p_option = true;
$dgrid->allowPaging($p_option);
## *** set paging settings
$bottom_paging = array("results"=>true, "results_align"=>"left", "pages"=>true, "pages_align"=>"center", "page_size"=>true, "page_size_align"=>"right");
$top_paging = array();
$dgrid->setPagingSettings($bottom_paging, $top_paging);
##
## Filter Settings
## --------------------------------------------------------
## *** set filtering option: true or false(default)
$f_option = true;
$dgrid->allowFiltering(true);
## *** set fileds in filtering mode:
$f_fileds = array(
"Country"=>array("table"=>"tblCountries", "field"=>"Name", "operator"=>true),
"Region"=>array("table"=>"tblRegions", "field"=>"Name", "operator"=>true),
"Population"=>array("table"=>"tblCountries", "field"=>"Population", "operator"=>true)
);
$dgrid->setFieldsFiltering($f_fileds);
##
## View Mode Settings:
## --------------------------------------------------------
## *** set columns in view mode
$vm_colimns = array(
"Region"=>array("header"=>"Region Name","type"=>"label", "text_length"=>"-1"),
"Name"=>array("header"=>"Country Name","type"=>"label", "text_length"=>"-1"),
"Population"=>array("header"=>"Population","type"=>"label", "text_length"=>"-1"),
"Description"=>array("header"=>"Short Description","type"=>"label", "text_length"=>"30"),
"PictureURL"=>array("header"=>"Picture","type"=>"link", "field"=>"PictureURL", "prefix"=>"http://", "target"=>"_new", "text_length"=>"-1")
);
$dgrid->setColumnsInViewMode($vm_colimns);
##
## Edit Mode settings:
## --------------------------------------------------------
## *** set settings for details mode
$table_name = "tblCountries";
$primary_key = "CountryID";
$dgrid->setTableEdit($table_name, $primary_key);
## *** set columns in edit mode
$em_columns = array(
"RegionID" =>array("header"=>"Region","type"=>"textbox","req_type"=>"rt", "title"=>"Region Name"),
"Name" =>array("header"=>"Country","type"=>"textbox","req_type"=>"ry", "title"=>"Country Name"),
"Description" =>array("header"=>"Short Descr.","type"=>"textarea","req_type"=>"rt", "title"=>"Short Description"),
"Population" =>array("header"=>"Peoples","type"=>"textbox","req_type"=>"ri", "title"=>"Population(Peoples)"),
"PictureURL" =>array("header"=>"ImageURL","type"=>"textbox","req_type"=>"rt", "title"=>"Image URL"),
"is_democracy" =>array("header"=>"IsDemocracy","type"=>"textbox","req_type"=>"sy", "title"=>"Is Democraty")
);
$dgrid->setColumnsInEditMode($em_columns);
## *** set foreign keys for edit mode
$f_keys = array(
"RegionID"=>array("table"=>"tblRegions", "field_key"=>"RegionID", "field_name"=>"Name", "view_type"=>"combobox"),
"is_democracy"=>array("table"=>"tblDemocracy ", "field_key"=>"did", "field_name"=>"description", "view_type"=>"radiobutton")
);
$dgrid->setForeignKeysEdit($f_keys);
##
## Bind the DataGrid:
## --------------------------------------------------------
## *** set debug mode & messaging options
$debug_mode = false;
$messaging = true;
$dgrid->bind($debug_mode, $messaging);
ob_end_flush();
##
########################################
?>
########################################
## Creating & Calling
## --------------------------------------------------------
require_once('datagrid/datagrid.class.php');
##
## *** creating variables that we need for database connection
$DB_USER='phpbuilder_dgrid'; // usually like this: prefix_name
$DB_PASS='12345'; // must be already enscrypted
$DB_HOST='db5.awardspace.com'; // often localhost
$DB_NAME='phpbuilder_dgrid'; // usually like this: prefix_name
ob_start();
$db_conn = mysql_connect($DB_HOST,$DB_USER,$DB_PASS);
mysql_select_db($DB_NAME,$db_conn);
## *** put primary key on the first place
$sql=" SELECT "
."tblCountries.CountryID, "
."tblRegions.Name as Region, "
."tblCountries.Name, "
."tblCountries.Description, "
."tblCountries.Population, "
."tblCountries.PictureURL, "
."tblDemocracy.description as is_democracy "
."FROM tblCountries INNER JOIN tblRegions ON tblCountries.RegionID=tblRegions.RegionID "
."LEFT OUTER JOIN tblDemocracy ON tblCountries.is_democracy=tblDemocracy.did ";
$dgrid = new DataGrid();
$dgrid->dataSource($db_conn, $sql);
##
## General Settings
## --------------------------------------------------------
## *** set unique prefix
$u_prefix = "_abc";
$dgrid->setUniqueNames($u_prefix);
## *** set direction: "ltr" or "rtr"
$direction = "ltr";
$dgrid->setDirection($direction);
## *** set layouts: 0 - tabular(horizontal) - default, 1 - columnar(vertical)
$layouts = array("view"=>0, "edit"=>1, "filter"=>1);
$dgrid->setLayouts($layouts);
## *** set other modes
$modes = array(
"add"=>array("view"=>true, "edit"=>false),
"edit"=>array("view"=>true, "edit"=>true, "byfield"=>""),
"cancel"=>array("allow"=>true,"view"=>true, "edit"=>true),
"details"=>array("view"=>true, "edit"=>false),
"delete"=>array("view"=>true, "edit"=>true)
);
$dgrid->setModes($modes);
## *** set nowrap attributes for all columns
$wrap = "nowrap";
$dgrid->setColumnsNoWrap($wrap);
## *** set CSS class for datagrid: "default" or "like adwords" or "salomon"
$css_class = "default";
$dgrid->setCssClass($css_class);
##
## Sorting & Paging Settings:
## ---------
## *** set sorting option: true(default) or false
$s_option = true;
$dgrid->allowSorting($s_option);
## *** set paging option: true(default) or false
$p_option = true;
$dgrid->allowPaging($p_option);
## *** set paging settings
$bottom_paging = array("results"=>true, "results_align"=>"left", "pages"=>true, "pages_align"=>"center", "page_size"=>true, "page_size_align"=>"right");
$top_paging = array();
$dgrid->setPagingSettings($bottom_paging, $top_paging);
##
## Filter Settings
## --------------------------------------------------------
## *** set filtering option: true or false(default)
$f_option = true;
$dgrid->allowFiltering(true);
## *** set fileds in filtering mode:
$f_fileds = array(
"Country"=>array("table"=>"tblCountries", "field"=>"Name", "operator"=>true),
"Region"=>array("table"=>"tblRegions", "field"=>"Name", "operator"=>true),
"Population"=>array("table"=>"tblCountries", "field"=>"Population", "operator"=>true)
);
$dgrid->setFieldsFiltering($f_fileds);
##
## View Mode Settings:
## --------------------------------------------------------
## *** set columns in view mode
$vm_colimns = array(
"Region"=>array("header"=>"Region Name","type"=>"label", "text_length"=>"-1"),
"Name"=>array("header"=>"Country Name","type"=>"label", "text_length"=>"-1"),
"Population"=>array("header"=>"Population","type"=>"label", "text_length"=>"-1"),
"Description"=>array("header"=>"Short Description","type"=>"label", "text_length"=>"30"),
"PictureURL"=>array("header"=>"Picture","type"=>"link", "field"=>"PictureURL", "prefix"=>"http://", "target"=>"_new", "text_length"=>"-1")
);
$dgrid->setColumnsInViewMode($vm_colimns);
##
## Edit Mode settings:
## --------------------------------------------------------
## *** set settings for details mode
$table_name = "tblCountries";
$primary_key = "CountryID";
$dgrid->setTableEdit($table_name, $primary_key);
## *** set columns in edit mode
$em_columns = array(
"RegionID" =>array("header"=>"Region","type"=>"textbox","req_type"=>"rt", "title"=>"Region Name"),
"Name" =>array("header"=>"Country","type"=>"textbox","req_type"=>"ry", "title"=>"Country Name"),
"Description" =>array("header"=>"Short Descr.","type"=>"textarea","req_type"=>"rt", "title"=>"Short Description"),
"Population" =>array("header"=>"Peoples","type"=>"textbox","req_type"=>"ri", "title"=>"Population(Peoples)"),
"PictureURL" =>array("header"=>"ImageURL","type"=>"textbox","req_type"=>"rt", "title"=>"Image URL"),
"is_democracy" =>array("header"=>"IsDemocracy","type"=>"textbox","req_type"=>"sy", "title"=>"Is Democraty")
);
$dgrid->setColumnsInEditMode($em_columns);
## *** set foreign keys for edit mode
$f_keys = array(
"RegionID"=>array("table"=>"tblRegions", "field_key"=>"RegionID", "field_name"=>"Name", "view_type"=>"combobox"),
"is_democracy"=>array("table"=>"tblDemocracy ", "field_key"=>"did", "field_name"=>"description", "view_type"=>"radiobutton")
);
$dgrid->setForeignKeysEdit($f_keys);
##
## Bind the DataGrid:
## --------------------------------------------------------
## *** set debug mode & messaging options
$debug_mode = false;
$messaging = true;
$dgrid->bind($debug_mode, $messaging);
ob_end_flush();
##
########################################
?>
Friday, October 13, 2006
The blog's Forum
Dear readers and visitors!
The Blog's forum is created to help Me and You to discuss any themes that related to PHP DataGrid script. If your question is about PHP DataGrid - please, leave it on the blog's Forum. It will really help me to prevent to get twice same answers.
Thanks :)
The Blog's forum is created to help Me and You to discuss any themes that related to PHP DataGrid script. If your question is about PHP DataGrid - please, leave it on the blog's Forum. It will really help me to prevent to get twice same answers.
Thanks :)
Monday, October 09, 2006
New version 2.1.0 of PHP DataGrid
New version 2.1.0 of PHP DataGrid is available for downloading from now.
Features of this version:
-------------------------
- View mode
-- Tabular layout
-- Columnar layout
- Details mode
-- Columnar layout
- Columns sorting
- Fields Filtering
- Paging
-- current/total pages selector
-- pager
-- page size drop-down box
- Embedded css templates
To download a new version click here.
To see Live Demo click here.
The new version comes in .rar archive that includes following files:
- datagrid.class.php
- example.php
- lisence.txt
- readme.txt
- documentation.txt
- SQL.txt
Features of this version:
-------------------------
- View mode
-- Tabular layout
-- Columnar layout
- Details mode
-- Columnar layout
- Columns sorting
- Fields Filtering
- Paging
-- current/total pages selector
-- pager
-- page size drop-down box
- Embedded css templates
To download a new version click here.
To see Live Demo click here.
The new version comes in .rar archive that includes following files:
- datagrid.class.php
- example.php
- lisence.txt
- readme.txt
- documentation.txt
- SQL.txt
Sunday, October 08, 2006
PHP DataGrid v.2.x.x
--------------------------------------------------------------
To download version 2.1.0 click here.
--------------------------------------------------------------
PHP DataGrid documentation for version 2.x.x
--------------------------------------------------------------
1. System Requirements
------------------------------
PHP DataGrid is operating system independent. You get it works on both Linux and
Windows. You need following components are installed:
- PHP 4.0 script engine or later
- Apache 1.3 or above
- mySQL 3.23 or above
2. Lisencing
------------------------------
See the Lisence.txt file.
3. Installation
------------------------------
<? require_once($PHP_DATAGRID_FILE_PATH."/datagrid.class") ?>
Where $PHP_DATAGRID_FILE_PATH - is a file path where PHPDataGrid stored on your server.
3. Features
------------------------------
- View mode
-- Tabular layout
-- Columnar layout
- Details mode
-- Columnar layout
- Columns sorting
- Fields Filtering
- Paging
-- current/total pages selector
-- pager
-- page size drop-down box
- Embedded css templates
To see example of code click here.
To download version 2.1.0 click here.
--------------------------------------------------------------
Saturday, October 07, 2006
Code example for PHP DataGrid v.2.x.x
We have 3 tables:
-- --------------------------------------------------------
--
-- Table structure for table `tblRegions`
--
CREATE TABLE `tblRegions` (
`RegionID` tinyint(3) unsigned NOT NULL auto_increment,
`Name` varchar(20) NOT NULL default '',
PRIMARY KEY (`RegionID`)
) ENGINE=MyISAM AUTO_INCREMENT=10 DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;
-- --------------------------------------------------------
--
-- Table structure for table `tblCountries`
--
CREATE TABLE `tblCountries` (
`CountryID` tinyint(3) unsigned NOT NULL auto_increment,
`RegionID` tinyint(3) unsigned NOT NULL default '0',
`Name` varchar(50) NOT NULL default '',
`Description` varchar(255) NOT NULL default '',
`Population` double unsigned NOT NULL default '0',
`PictureURL` varchar(100) NOT NULL default '',
`is_democracy` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`CountryID`)
) ENGINE=MyISAM AUTO_INCREMENT=228 DEFAULT CHARSET=latin1 AUTO_INCREMENT=228 ;
-- --------------------------------------------------------
--
-- Table structure for table `tblDemocracy`
--
CREATE TABLE `tblDemocracy` (
`did` int(10) unsigned NOT NULL auto_increment,
`description` varchar(20) NOT NULL default '',
PRIMARY KEY (`did`)
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
The code example:
<?
require_once('datagrid.class.php');
// Creating & Calling
// --------------------------------------------------------------------------------- ob_start();
$DB_USER='username'; // usually like this: prefix_username
$DB_PASS='12345'; // must be already enscrypted
$DB_HOST='localhost'; // often localhost
$DB_NAME='dbname'; // usually like this: prefix_dbname
$db_conn=mysql_connect($DB_HOST,$DB_USER,$DB_PASS); mysql_select_db($DB_NAME,$db_conn);
$sql=" SELECT "
."tblCountries.CountryID, "
."tblCountries.Name, "
."tblCountries.Description, "
."tblCountries.Population, "
."tblCountries.PictureURL, "
."tblRegions.Name as Region, "
."tblDemocracy.description as is_democracy "
."FROM tblCountries INNER JOIN tblRegions ON
tblCountries.RegionID=tblRegions.RegionID "
."LEFT OUTER JOIN tblDemocracy ON tblCountries.is_democracy=tblDemocracy.did ";
$dgrid = new DataGrid();
$dgrid->dataSourse($db_conn, $sql);
// General Settings
// ---------
/*** set unique prefix, ex.: $unames = "_abc" */
$dgrid->setUniqueNames("_abc");
/*** set layouts, ex.: $layouts = array("view"=>0) where 0-tabular(default), 1-columnar */
$dgrid->setLayouts(array("view"=>0));
/*** set other modes */
$dgrid->setModes(array("details"=>array("view"=>true)));
/*** set for all columns, ex.: $wrap = "nowrap" */
$dgrid->setColumnsNoWrap("nowrap");
/*** set CSS class for datagrid, ex.: $class = "default"/"Like Adwords"/"salomon"/ */
$dgrid->setCssClass("default");
// Sorting & Paging Settings:
// ---------
/*** set sorting option, ex.: $s_option = true(default)/false */
$dgrid->allowSorting(true);
/*** set paging option, ex.: $p_option = true(default)/false */
$dgrid->allowPaging(true);
/*** set paging settings */
$top_paging = array();
$bottom_paging = array("results"=>true, "results_align"=>"left", "pages"=>true, "pages_align"=>"center", "page_size"=>true, "page_size_align"=>"right");
$dgrid->setPagingSettings($bottom_paging, $top_paging);
// Filtering Settings
// ---------
/*** $option: true/false; default - false */
$dgrid->allowFiltering(true);
/*** set fileds for filtering */
$f_fields = array(
"Country"=>array("table"=>"tblCountries", "field"=>"Name"),
"Region"=>array("table"=>"tblRegions", "field"=>"Name"),
"Democracy"=>array("table"=>"tblDemocraty", "field"=>"description")
);
$dgrid->setFieldsFiltering($f_fields);
// View Mode Settings:
// ---------
/*** set columns in view mode */
$vm_columns = array(
"Name" =>array("header"=>"Country", "type"=>"label"),
"Region" =>array("header"=>"Region", "type"=>"label"),
"Description" =>array("header"=>"Short Descr.", "type"=>"label"),
"Population" =>array("header"=>"Peoples", "type"=>"label"),
"PictureURL" =>array("header"=>"ImageURL", "type"=>"link", "href"=>"www.yahoo.com", "target"=>"_new"),
"is_democracy" =>array("header"=>"IsDemocracy", "type"=>"label")
);
$dgrid->setColumnsInViewMode($vm_columns);
// Details Mode settings:
// ------------------
/*** set settings for details mode */
$table_name = "tblCountries";
$primary_key = "CountryID";
$dgrid->setTableEdit($table_name, $primary_key);
/*** set columns in details mode */
$e_columns = array(
"RegionID" =>array("header"=>"Region","type"=>"textbox"),
"Name" =>array("header"=>"Country","type"=>"textarea"),
"Description" =>array("header"=>"Short Descr.","type"=>"date"),
"Population" =>array("header"=>"Peoples","type"=>"textbox"),
"PictureURL" =>array("header"=>"ImageURL","type"=>"textbox"),
"is_democracy" =>array("header"=>"IsDemocracy","type"=>"textbox")
);
$dgrid->setColumnsInEditMode($e_columns);
/*** set foreign keys for details mode table */
$f_keys = array(
"RegionID"=>array("table"=>"tblRegions", "field_key"=>"RegionID", "field_name"=>"Name"),
"is_democraty"=>array("table"=>"tblDemocraty ", "field_key"=>"did", "field_name"=>"description")
);
$dgrid->setForeignKeysEdit($f_keys);
// Bind the DataGrid:
// ---------
/*** set debug mode & messaging options */
$debug_mode = false;
$messaging = false;
$dgrid->bind($debug_mode, $messaging);
ob_end_flush();
?>
-- --------------------------------------------------------
--
-- Table structure for table `tblRegions`
--
CREATE TABLE `tblRegions` (
`RegionID` tinyint(3) unsigned NOT NULL auto_increment,
`Name` varchar(20) NOT NULL default '',
PRIMARY KEY (`RegionID`)
) ENGINE=MyISAM AUTO_INCREMENT=10 DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;
-- --------------------------------------------------------
--
-- Table structure for table `tblCountries`
--
CREATE TABLE `tblCountries` (
`CountryID` tinyint(3) unsigned NOT NULL auto_increment,
`RegionID` tinyint(3) unsigned NOT NULL default '0',
`Name` varchar(50) NOT NULL default '',
`Description` varchar(255) NOT NULL default '',
`Population` double unsigned NOT NULL default '0',
`PictureURL` varchar(100) NOT NULL default '',
`is_democracy` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`CountryID`)
) ENGINE=MyISAM AUTO_INCREMENT=228 DEFAULT CHARSET=latin1 AUTO_INCREMENT=228 ;
-- --------------------------------------------------------
--
-- Table structure for table `tblDemocracy`
--
CREATE TABLE `tblDemocracy` (
`did` int(10) unsigned NOT NULL auto_increment,
`description` varchar(20) NOT NULL default '',
PRIMARY KEY (`did`)
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
The code example:
<?
require_once('datagrid.class.php');
// Creating & Calling
// --------------------------------------------------------------------------------- ob_start();
$DB_USER='username'; // usually like this: prefix_username
$DB_PASS='12345'; // must be already enscrypted
$DB_HOST='localhost'; // often localhost
$DB_NAME='dbname'; // usually like this: prefix_dbname
$db_conn=mysql_connect($DB_HOST,$DB_USER,$DB_PASS); mysql_select_db($DB_NAME,$db_conn);
$sql=" SELECT "
."tblCountries.CountryID, "
."tblCountries.Name, "
."tblCountries.Description, "
."tblCountries.Population, "
."tblCountries.PictureURL, "
."tblRegions.Name as Region, "
."tblDemocracy.description as is_democracy "
."FROM tblCountries INNER JOIN tblRegions ON
tblCountries.RegionID=tblRegions.RegionID "
."LEFT OUTER JOIN tblDemocracy ON tblCountries.is_democracy=tblDemocracy.did ";
$dgrid = new DataGrid();
$dgrid->dataSourse($db_conn, $sql);
// General Settings
// ---------
/*** set unique prefix, ex.: $unames = "_abc" */
$dgrid->setUniqueNames("_abc");
/*** set layouts, ex.: $layouts = array("view"=>0) where 0-tabular(default), 1-columnar */
$dgrid->setLayouts(array("view"=>0));
/*** set other modes */
$dgrid->setModes(array("details"=>array("view"=>true)));
/*** set for all columns, ex.: $wrap = "nowrap" */
$dgrid->setColumnsNoWrap("nowrap");
/*** set CSS class for datagrid, ex.: $class = "default"/"Like Adwords"/"salomon"/ */
$dgrid->setCssClass("default");
// Sorting & Paging Settings:
// ---------
/*** set sorting option, ex.: $s_option = true(default)/false */
$dgrid->allowSorting(true);
/*** set paging option, ex.: $p_option = true(default)/false */
$dgrid->allowPaging(true);
/*** set paging settings */
$top_paging = array();
$bottom_paging = array("results"=>true, "results_align"=>"left", "pages"=>true, "pages_align"=>"center", "page_size"=>true, "page_size_align"=>"right");
$dgrid->setPagingSettings($bottom_paging, $top_paging);
// Filtering Settings
// ---------
/*** $option: true/false; default - false */
$dgrid->allowFiltering(true);
/*** set fileds for filtering */
$f_fields = array(
"Country"=>array("table"=>"tblCountries", "field"=>"Name"),
"Region"=>array("table"=>"tblRegions", "field"=>"Name"),
"Democracy"=>array("table"=>"tblDemocraty", "field"=>"description")
);
$dgrid->setFieldsFiltering($f_fields);
// View Mode Settings:
// ---------
/*** set columns in view mode */
$vm_columns = array(
"Name" =>array("header"=>"Country", "type"=>"label"),
"Region" =>array("header"=>"Region", "type"=>"label"),
"Description" =>array("header"=>"Short Descr.", "type"=>"label"),
"Population" =>array("header"=>"Peoples", "type"=>"label"),
"PictureURL" =>array("header"=>"ImageURL", "type"=>"link", "href"=>"www.yahoo.com", "target"=>"_new"),
"is_democracy" =>array("header"=>"IsDemocracy", "type"=>"label")
);
$dgrid->setColumnsInViewMode($vm_columns);
// Details Mode settings:
// ------------------
/*** set settings for details mode */
$table_name = "tblCountries";
$primary_key = "CountryID";
$dgrid->setTableEdit($table_name, $primary_key);
/*** set columns in details mode */
$e_columns = array(
"RegionID" =>array("header"=>"Region","type"=>"textbox"),
"Name" =>array("header"=>"Country","type"=>"textarea"),
"Description" =>array("header"=>"Short Descr.","type"=>"date"),
"Population" =>array("header"=>"Peoples","type"=>"textbox"),
"PictureURL" =>array("header"=>"ImageURL","type"=>"textbox"),
"is_democracy" =>array("header"=>"IsDemocracy","type"=>"textbox")
);
$dgrid->setColumnsInEditMode($e_columns);
/*** set foreign keys for details mode table */
$f_keys = array(
"RegionID"=>array("table"=>"tblRegions", "field_key"=>"RegionID", "field_name"=>"Name"),
"is_democraty"=>array("table"=>"tblDemocraty ", "field_key"=>"did", "field_name"=>"description")
);
$dgrid->setForeignKeysEdit($f_keys);
// Bind the DataGrid:
// ---------
/*** set debug mode & messaging options */
$debug_mode = false;
$messaging = false;
$dgrid->bind($debug_mode, $messaging);
ob_end_flush();
?>
Thursday, October 05, 2006
New version 1.1.1 of PHP DataGrid
New version 1.1.1 of PHP DataGrid is available for downloading now.
Latest changes:
- fixed bugs in getHeaderName()
- fixed bugs in noDataFound()
- fixed bugs in setColumnsInViewMode()
To download a new version click here.
Latest changes:
- fixed bugs in getHeaderName()
- fixed bugs in noDataFound()
- fixed bugs in setColumnsInViewMode()
To download a new version click here.
Tuesday, October 03, 2006
A few additions
1. Idea
------------------------------
The main idea behind the PHP DataGrid class is the full incapsulation of all needed methods. And also... creation, as fast as possible (few minutes), a good working application.
2. Next version
------------------------------
2nd version comming soon and version 3.xx too... I can't simply upload my non-edited code that I wrote for myself. Sorry, but it should have a better look. It will take a little bit of time :)
3. Good news
------------------------------
Version 2.x.x comes with example of data base.
P.S. Special thanks for your letters with comments. But, please... leave them here.
------------------------------
The main idea behind the PHP DataGrid class is the full incapsulation of all needed methods. And also... creation, as fast as possible (few minutes), a good working application.
2. Next version
------------------------------
2nd version comming soon and version 3.xx too... I can't simply upload my non-edited code that I wrote for myself. Sorry, but it should have a better look. It will take a little bit of time :)
3. Good news
------------------------------
Version 2.x.x comes with example of data base.
P.S. Special thanks for your letters with comments. But, please... leave them here.
Saturday, September 30, 2006
Site's look
In the future the look of the site will be more friendly. I work on improving him and aditing some useful things, but this process will take me a time.
First version of PHP DataGrid is ready for downloading!
The first (and my be not a last) PHP script I put on here is a PHP DataGrid. This script (PHP class) I wrote for myself for some projects where data base management was needed.
It was so comfortable and useful that I desided to continue to improve him and farther. Now you can download a version 1.1.0. Last versions soon also will be available for downloading. This is because I need to prepare the code and make it more readable.
To get a help, read description and to see an example of code click here.
It was so comfortable and useful that I desided to continue to improve him and farther. Now you can download a version 1.1.0. Last versions soon also will be available for downloading. This is because I need to prepare the code and make it more readable.
To get a help, read description and to see an example of code click here.
The first post
Hi! This is my first post on this blog. I just started it now and I hope it will be very useful for peoples who work with PHP. All stuff I will post and all scripts will be absolutly free. So... Ok, go on...
Tuesday, August 29, 2006
PHP DataGrid v.1.x.x
--------------------------------------------------------------
To download version 1.1.1 click here.
This version changes:
- fixed bugs in getHeaderName()
- fixed bugs in noDataFound()
- fixed bugs in setColumnsInViewMode()
- fixed bugs in combine_url()
- fixed bugs in setCssClass()
To download version 1.1.0 click here.
--------------------------------------------------------------
PHP DataGrid document for version 1.x.x
--------------------------------------------------------------
1. System Requirements
------------------------------
PHP DataGrid is operating system independent. You get it works on both Linux and
Windows. You need following components are installed:
- PHP 4.0 script engine or later
- Apache 1.3 or above
- mySQL 3.23 or above
2. Installation
------------------------------
<? include("$PHP_DATAGRID_FILE_PATH/datagrid.class") ?>
Where $PHP_DATAGRID_FILE_PATH - is a file path where PHPDataGrid stored on your server.
You may also use require() PHP function instead of include().
3. Features
------------------------------
- View mode
- Columns sorting
- Paging
-- current/total pages selector
-- pager
-- page size drop-down box
- embedded css templates
To see an example of code click here.
To download version 1.1.1 click here.
--------------------------------------------------------------
Monday, August 28, 2006
Examples of code PHP DataGrid v.1.x.x
In datagrid.class file you can find commented lines of how to create, call and work with this class.
All you need is to copy all commented lines of the code into you page and uncomment some lines. That's all!
Now we'll check this example to get you understanding how it works.
For example, we have a database (mySQL) with 3 tables:
country
CountryID
RegionID
Name
Description
Population
PictureURL
democraty
regions
RegionID
Name
democracy
did
description
// creating variables that we need for database connection
$DB_USER='root'; // often like this: prefix_name
$DB_PASS=''; // must be already enscrypted
$DB_HOST='localhost'; // often localhost
$DB_NAME='thebutto_test'; // often like this: prefix_name
ob_start();
// now we create connection with our database
$db_conn=mysql_connect($DB_HOST,$DB_USER,$DB_PASS); mysql_select_db($DB_NAME,$db_conn);
// create sql statment (any SELECT statment you want)
// it's recomended to put Primary Key at the first place (CountryID in this example)
$sql="SELECT ".
" countries.CountryID, ".
" countries.Name, ".
" regions.Name as Region, ".
" countries.Description, ".
" countries.Population, ".
" countries.PictureURL, ".
" democraty.description as isdemocraty ".
" FROM countries ".
" INNER JOIN regions ON countries.regionID=regions.regionID ".
" LEFT OUTER JOIN democraty ON countries.democraty=democraty.did ";
// creating a new instance of DataGrid class
$dgrid = new DataGrid();
// linking data source with DataGrid
$dgrid->dataSourse($db_conn, $sql);
// General Settings
// ---------
/*** here we give unique names for HTML elements */
$dgrid->setUniqueNames("_abc");
/*** wich layout we want: 0-tabular(default), 1-columnar */
$dgrid->setLayouts(array("view"=>0));
/*** set for all columns 'nowrap' parameter */
$dgrid->setColumnsNoWrap("nowrap");
/*** set css class, default: "default" */
$dgrid->setCssClass("default");
// Sorting & Paging Settings:
// ---------
/*** allow sorting on columns: true/false; default - true */
$dgrid->allowSorting(true);
/*** allow paging option: true/false; default - true */
$dgrid->allowPaging(true);
/*** set paging settings: on top & bottom
$dgrid->setPagingSettings(
array("results"=>true, "results_align"=>"left",
"pages"=>true, "pages_align"=>"center",
"page_size"=>true, "page_size_align"=>"right"),
array()
);
// View Mode Settings:
// ---------
/*** set view mode settings: */
$dgrid->setColumnsInViewMode(array(
"Name" =>array("header"=>"Country","type"=>"label"),
"Region" =>array("header"=>"Region","type"=>"label"),
"PictureURL" =>array("header"=>"Image","type"=>"link",
"href"=>"http://www.yahoo.com", "target"=>"_new"),
"isdemocraty" =>array("header"=>"Is Democraty","type"=>"label")
));
/*** set debug mode = true/false(default) $ messaging = true(default)/false */
$dgrid->bind(false, false);
ob_end_flush();
Now, let's see what we've got:
All you need is to copy all commented lines of the code into you page and uncomment some lines. That's all!
Now we'll check this example to get you understanding how it works.
For example, we have a database (mySQL) with 3 tables:
country
CountryID
RegionID
Name
Description
Population
PictureURL
democraty
regions
RegionID
Name
democracy
did
description
// creating variables that we need for database connection
$DB_USER='root'; // often like this: prefix_name
$DB_PASS=''; // must be already enscrypted
$DB_HOST='localhost'; // often localhost
$DB_NAME='thebutto_test'; // often like this: prefix_name
ob_start();
// now we create connection with our database
$db_conn=mysql_connect($DB_HOST,$DB_USER,$DB_PASS); mysql_select_db($DB_NAME,$db_conn);
// create sql statment (any SELECT statment you want)
// it's recomended to put Primary Key at the first place (CountryID in this example)
$sql="SELECT ".
" countries.CountryID, ".
" countries.Name, ".
" regions.Name as Region, ".
" countries.Description, ".
" countries.Population, ".
" countries.PictureURL, ".
" democraty.description as isdemocraty ".
" FROM countries ".
" INNER JOIN regions ON countries.regionID=regions.regionID ".
" LEFT OUTER JOIN democraty ON countries.democraty=democraty.did ";
// creating a new instance of DataGrid class
$dgrid = new DataGrid();
// linking data source with DataGrid
$dgrid->dataSourse($db_conn, $sql);
// General Settings
// ---------
/*** here we give unique names for HTML elements */
$dgrid->setUniqueNames("_abc");
/*** wich layout we want: 0-tabular(default), 1-columnar */
$dgrid->setLayouts(array("view"=>0));
/*** set for all columns 'nowrap' parameter */
$dgrid->setColumnsNoWrap("nowrap");
/*** set css class, default: "default" */
$dgrid->setCssClass("default");
// Sorting & Paging Settings:
// ---------
/*** allow sorting on columns: true/false; default - true */
$dgrid->allowSorting(true);
/*** allow paging option: true/false; default - true */
$dgrid->allowPaging(true);
/*** set paging settings: on top & bottom
$dgrid->setPagingSettings(
array("results"=>true, "results_align"=>"left",
"pages"=>true, "pages_align"=>"center",
"page_size"=>true, "page_size_align"=>"right"),
array()
);
// View Mode Settings:
// ---------
/*** set view mode settings: */
$dgrid->setColumnsInViewMode(array(
"Name" =>array("header"=>"Country","type"=>"label"),
"Region" =>array("header"=>"Region","type"=>"label"),
"PictureURL" =>array("header"=>"Image","type"=>"link",
"href"=>"http://www.yahoo.com", "target"=>"_new"),
"isdemocraty" =>array("header"=>"Is Democraty","type"=>"label")
));
/*** set debug mode = true/false(default) $ messaging = true(default)/false */
$dgrid->bind(false, false);
ob_end_flush();
Now, let's see what we've got:
Sunday, August 27, 2006
PHP DataGrid Version Comparison
This is a general version comparison for PHP DataGrid class:
Ver. 1.x.x | Ver. 2.x.x | Ver. 3.x.x | Ver. 4.x.x | |
CSS emb.templates | Yes | Yes | Yes | Yes |
Column sorting | Yes | Yes | Yes | Yes |
Filtering | No | Yes | Yes | Yes |
Pagging | Yes | Yes | Yes | Yes |
Exporting | No | No | No | Yes |
Printing | No | No | No | Yes |
Automatic validation | No | No | Yes | Yes |
-- Client side | No | No | Yes | Yes |
-- Server side | No | No | No | No |
View mode | Yes | Yes | Yes | Yes |
-- Tabular layout | Yes | Yes | Yes | Yes |
-- Columnar layout | Yes | Yes | Yes | Yes |
Details mode | No | Yes | Yes | Yes |
-- Columnar layout | No | Yes | Yes | Yes |
Add new mode | No | No | Yes | Yes |
-- Tabular layout | No | No | Yes | Yes |
-- Columnar layout | No | No | Yes | Yes |
Edit mode | No | No | Yes | Yes |
-- Tabular layout | No | No | Yes | Yes |
-- Columnar layout | No | No | Yes | Yes |
Delete mode | No | No | Yes | Yes |
Multi-Database support | No | No | No | Yes |
Multi-Language support | No | No | No | Yes |
Multi-Browser support | No | No | No | Yes |
W3C CSS validation | No | No | No | Yes |
WYSIWYG editor | No | No | No | Yes |
Saturday, August 26, 2006
FAQ
1. Who you are?
2. Why you do it?
3. Is all scripts on this blog are absolutely free?
4. What to do if I found bug/s?
5. What to do if I can't run a script?
6. How can I to subscribe for the blog news?
7. How can I help to the PHP Builder project?
Q1: Who you are?
A1:
^ top
Q2: Why you do it?
A2: I really do not know. :) May be because... I like PHP programming and I want people will like it too. Also I want to create something useful... very and very nice product, which will give to PHP programmers an advantage. Anyway, until I like it - this site will be live.
^ top
Q3: Is all scripts on this blog are absolutely free?
A3: Yes, you can use it for yourself, in your projects, but you could not sell these scripts. For more information, see a license for each script (included in downloading archive).
^ top
Q4: What to do if I found bug/s?
A4: Post you message on the forum of the blog (recommended) or send me e-mail.
^ top
Q5: What to do if I can not run a script?
A5: Post your message on blog's forum with example of your code or error description.
^ top
Q6: How can I to subscribe for the blog news?
A6: Just click here and follow instructions.
^ top
Q7: How can I help to the PHP Builder project?
A7: Read here about different ways to help the project.
^ top
Monday, July 31, 2006
Installation
PHP DataGrid - Step by Step.
NEW INSTALLATION (for version 3.x.x or above)
========================================================
Step 1.
--------------------------------------------------------
Upload the code_template.php file and folder named "datagrid" (with all files it includes) to your document root (public_html, www, htdocs etc.) using FTP.
For example:
public_html/your_site/code_template.php
public_html/your_site/datagrid
Step 2.
--------------------------------------------------------
Using phpMyAdmin or another tool, create your database and user,
and assign that user to the database. Write down the name of the database,
username, and password for this database for the database installation
procedure.
Create all appropriate database tables.
Step 3.
--------------------------------------------------------
Open code_template.php file, uncomment these 4 lines and change variable
values on yours (saved on step 3).
// $DB_USER='name'; /* usually like this: prefix_name */
// $DB_PASS=''; /* must be already enscrypted (recommended) */
// $DB_HOST='localhost'; /* usually localhost */
// $DB_NAME='dbName'; /* usually like this: prefix_dbName */
Step 4.
--------------------------------------------------------
Rename code_template.php file according to your needs.
Congradulations, you have PHP DataGrid Installed now!
NEW INSTALLATION (for version 3.x.x or above)
========================================================
Step 1.
--------------------------------------------------------
Upload the code_template.php file and folder named "datagrid" (with all files it includes) to your document root (public_html, www, htdocs etc.) using FTP.
For example:
public_html/your_site/code_template.php
public_html/your_site/datagrid
Step 2.
--------------------------------------------------------
Using phpMyAdmin or another tool, create your database and user,
and assign that user to the database. Write down the name of the database,
username, and password for this database for the database installation
procedure.
Create all appropriate database tables.
Step 3.
--------------------------------------------------------
Open code_template.php file, uncomment these 4 lines and change variable
values on yours (saved on step 3).
// $DB_USER='name'; /* usually like this: prefix_name */
// $DB_PASS=''; /* must be already enscrypted (recommended) */
// $DB_HOST='localhost'; /* usually localhost */
// $DB_NAME='dbName'; /* usually like this: prefix_dbName */
Step 4.
--------------------------------------------------------
Rename code_template.php file according to your needs.
Congradulations, you have PHP DataGrid Installed now!
Saturday, July 29, 2006
Getting Started
PHP DataGrid - Step by Step.
Step 1.
+---------------------------------------------------------------------------+
| Creating & Calling:
+---------------------------------------------------------------------------+
Be sure you write here a true path to the datagrid.class.php file, relatively to this file.
require_once('datagrid/datagrid.class.php');
Write true values to these variable. Be sure you use a prefix if you need it.
## *** creating variables that we need for database connection
$DB_USER='name'; /* usually like this: prefix_name */
$DB_PASS=''; /* must be already enscrypted (recommended) */
$DB_HOST='localhost'; /* usually localhost */
$DB_NAME='dbName'; /* usually like this: prefix_dbName */
First of all we need to be connected to database.
$db_conn = mysql_connect($DB_HOST,$DB_USER,$DB_PASS);
mysql_select_db($DB_NAME,$db_conn);
Now you have to prepare SELECT SQL statement. It can be any type of SELECT statement your database supports (with JOIN, UNION etc.), but you must put the primary key on the first place. Also be careful to write all fileds you need to be shown, because the DataGrid class works with only fields you placed in SELECT statement. Don't add here ORDER BY, LIMIT words or ; at the end of the statement.
## *** put a primary key on the first place
$sql = "SELECT primary_key, filed_1, filed_2 ... FROM tableName ";
Creating the new class instance and linking the DataGrid class to our database.
$debug_mode = false;
$messaging = true;
$dgrid = new DataGrid($debug_mode, $messaging);
$dgrid->dataSource($db_conn, $sql);
Step 2.
+---------------------------------------------------------------------------+
| General Settings:
+---------------------------------------------------------------------------+
We can add an unique prefix (optional) to our datagrid if we want to prevent using of double names on this page (in case, when you use some datagrids or forms on one page)
## *** set unique prefix
$u_prefix = "_abc";
$dgrid->setUniqueNames($u_prefix);
If you want to use a local language (not English) - you have to set the right
encoding. The properly fields in your database must be created with the same CHARACTER SET.
## *** set encoding (default - utf8)
$dg_encoding = "utf8";
$dgrid->setEncoding($dg_encoding);
Option for some right-to-left languages (Hebrew, Arabic etc.)
## *** set direction: "ltr" or "rtr" (default - ltr)
$direction = "ltr";
$dgrid->setDirection($direction);
Set layouts for datagrid in view mode, edit mode and for the filtering block
## *** set layouts: 0 - tabular(horizontal) - default, 1 - columnar(vertical)
$layouts = array("view"=>0, "edit"=>1, filter=1);
$dgrid->setLayouts($layouts);
Set various modes for datagrid.
True - allow the operation in this mode("view" or "edit"), false - don't allow.
Type - a type of command button (link, html button or image).
byFieldValue - if you want to make this field to be a link to edit mode page (instead of edit button), write here a name of the field. If you want to use a standart edit command button leave it empty - "byFieldValue"=>""
## *** set other modes ("type" = "link|button|image"), ("byFieldValue" - make the field as a link to edit mode page)
$modes = array(
"add"=>array("view"=>true, "edit"=>false, "type"=>"link"),
"edit"=>array("view"=>true, "edit"=>true, "type"=>="link", "byFieldValue"=>"FieldName"),
"cancel"=>array("view"=>true, "edit"=>true, "type"=>="link"),
"details"=>array("view"=>true, "edit"=>false, "type"=>="link"),
"delete"=>array("view"=>true, "edit"=>true, "type"=>="image")
);
$dgrid->setModes($modes);
Set "nowrap" attribute for all columns in the datagrid.
## *** set nowrap attribute for all columns
$wrap = "nowrap";
$dgrid->setColumnsNoWrap($wrap);
Set CSS parameters for the datagrid. If you want to use embedded css class - define $css_type as "embedded" and $css_class as you wish. If you use external file of CSS styles - you define $css_type as "file" and $css_class as full path to your file. For example: $css_class = "../css/datagrid_style.css". Embedded CSS styles: "default", "gray", "like adwords" and "salomon".
## *** set CSS class for datagrid:
$css_class = "default";
$css_type = "embedded";
$dgrid->setCssClass($css_class, $css_type);
To be continued...
Step 3.
+---------------------------------------------------------------------------+
| Printing & Exporting Settings:
+---------------------------------------------------------------------------+
Set printing as true, if you want to allow this option
## *** set printing option: true(default) or false
$printing_option = true;
$dgrid->allowPrinting($printing_option);
Set exporting as true, if you want to allow this option
## *** set exporting option: true(default) or false
$exporting_option = true;
$dgrid->allowExporting($exporting_option);
Step 4.
+---------------------------------------------------------------------------+
| Sorting & Paging Settings:
+---------------------------------------------------------------------------+
Set sorting option as true, if you want to allow sorting on columns
## *** set sorting option: true(default) or false
$$sorting_option = true;
$dgrid->allowSorting($$sorting_option);
Set paging option as true, if you want to allow paging on datagrid
## *** set paging option: true(default) or false
$paging_option = true;
$dgrid->allowPaging($paging_option);
Set aditional paging settings. $bottom_paging or $top_paging are defines both (top and bottom) paging behaviour. We have thee part of paging line: results, pages and page_size dropdownbox. You need to set parameters for each of them. If you don't want to show any of them - leave it empty (Ex.: $bottom_paging = array()). If you want to define your own dropdown box with page sizes - you can make it in $pages_array array - see example below. Also you need to define default page size in $default_page_size variable.
## *** set paging settings
$bottom_paging = array("results"=>true, "results_align"=>"left", "pages"=>true, "pages_align"=>"center", "page_size"=>true, "page_size_align"=>"right");
$top_paging = array("results"=>true, "results_align"=>"left", "pages"=>true, "pages_align"=>"center", "page_size"=>true, "page_size_align"=>"right");
$pages_array = array(10, 25, 50, 100, 250, 500, 1000);
$default_page_size = 10;
$dgrid->setPagingSettings($bottom_paging, $top_paging, $pages_array, $default_page_size);
Step 5.
+---------------------------------------------------------------------------+
| 5. Filter Settings:
+---------------------------------------------------------------------------+
If you want to allow filtering mode, set $filtering_option as true.
## *** set filtering option: true or false(default)
$filtering_option = true;
$dgrid->allowFiltering($filtering_option);
To be continued...
Step 5.
+---------------------------------------------------------------------------+
| 6. View Mode Settings:
+---------------------------------------------------------------------------+
This method sets up columns, that will be viewable.
"header"=>"..." - name of the column header
"type"=>"..." - type of column: label, image, linktoview, link (http://, mailto:) or password
"align"=>"..." - alignment of the column data (left or right)
"wrap"=>"..." - wraping of the column data (wrap or nowrap)
"text_length"=>"..." - viewable text length (any number, "-1" - don't truncate )
"case"=>"..." - text case (normal or upper or lower)
## *** set columns in view mode
$vm_colimns = array(
"FieldName_1"=>array("header"=>"Name_A", "type"=>"label", "align"=>"left", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "case"=>"normal|upper|lower"),
"FieldName_2"=>array("header"=>"Name_B", "type"=>"image", "align"=>"left", "wrap"=>"wrap|nowrap", "text_length"=>'-1', "case"=>"normal|upper|lower"),
"FieldName_3"=>array("header"=>"Name_C", "type"=>"linktoview", "align"=>"left", "wrap"=>"wrap|nowrap", "text_length"=>'-1', "case"=>"normal|upper|lower"),
"FieldName_4"=>array("header"=>"Name_D", "type"=>"link", "align"=>"left", "wrap"=>"wrap|nowrap", "href"=>"www.yahoo.com", "target"=>"_new", "text_length"=>"-1", "case"=>"normal|upper|lower"),
"FieldName_5"=>array("header"=>"Name_E", "type"=>"link", "align"=>"left", "wrap"=>"wrap|nowrap", "field"=>"field_name", "prefix"=>"http://", "target"=>"_new", "text_length"=>"-1", "case"=>"normal|upper|lower"),
"FieldName_6"=>array("header"=>"Name_F", "type"=>"password", "align"=>"left", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "case"=>"normal|upper|lower")
);
$dgrid->setColumnsInViewMode($vm_colimns);
To be continued...
Step 1.
+---------------------------------------------------------------------------+
| Creating & Calling:
+---------------------------------------------------------------------------+
Be sure you write here a true path to the datagrid.class.php file, relatively to this file.
require_once('datagrid/datagrid.class.php');
Write true values to these variable. Be sure you use a prefix if you need it.
## *** creating variables that we need for database connection
$DB_USER='name'; /* usually like this: prefix_name */
$DB_PASS=''; /* must be already enscrypted (recommended) */
$DB_HOST='localhost'; /* usually localhost */
$DB_NAME='dbName'; /* usually like this: prefix_dbName */
First of all we need to be connected to database.
$db_conn = mysql_connect($DB_HOST,$DB_USER,$DB_PASS);
mysql_select_db($DB_NAME,$db_conn);
Now you have to prepare SELECT SQL statement. It can be any type of SELECT statement your database supports (with JOIN, UNION etc.), but you must put the primary key on the first place. Also be careful to write all fileds you need to be shown, because the DataGrid class works with only fields you placed in SELECT statement. Don't add here ORDER BY, LIMIT words or ; at the end of the statement.
## *** put a primary key on the first place
$sql = "SELECT primary_key, filed_1, filed_2 ... FROM tableName ";
Creating the new class instance and linking the DataGrid class to our database.
$debug_mode = false;
$messaging = true;
$dgrid = new DataGrid($debug_mode, $messaging);
$dgrid->dataSource($db_conn, $sql);
Step 2.
+---------------------------------------------------------------------------+
| General Settings:
+---------------------------------------------------------------------------+
We can add an unique prefix (optional) to our datagrid if we want to prevent using of double names on this page (in case, when you use some datagrids or forms on one page)
## *** set unique prefix
$u_prefix = "_abc";
$dgrid->setUniqueNames($u_prefix);
If you want to use a local language (not English) - you have to set the right
encoding. The properly fields in your database must be created with the same CHARACTER SET.
## *** set encoding (default - utf8)
$dg_encoding = "utf8";
$dgrid->setEncoding($dg_encoding);
Option for some right-to-left languages (Hebrew, Arabic etc.)
## *** set direction: "ltr" or "rtr" (default - ltr)
$direction = "ltr";
$dgrid->setDirection($direction);
Set layouts for datagrid in view mode, edit mode and for the filtering block
## *** set layouts: 0 - tabular(horizontal) - default, 1 - columnar(vertical)
$layouts = array("view"=>0, "edit"=>1, filter=1);
$dgrid->setLayouts($layouts);
Set various modes for datagrid.
True - allow the operation in this mode("view" or "edit"), false - don't allow.
Type - a type of command button (link, html button or image).
byFieldValue - if you want to make this field to be a link to edit mode page (instead of edit button), write here a name of the field. If you want to use a standart edit command button leave it empty - "byFieldValue"=>""
## *** set other modes ("type" = "link|button|image"), ("byFieldValue" - make the field as a link to edit mode page)
$modes = array(
"add"=>array("view"=>true, "edit"=>false, "type"=>"link"),
"edit"=>array("view"=>true, "edit"=>true, "type"=>="link", "byFieldValue"=>"FieldName"),
"cancel"=>array("view"=>true, "edit"=>true, "type"=>="link"),
"details"=>array("view"=>true, "edit"=>false, "type"=>="link"),
"delete"=>array("view"=>true, "edit"=>true, "type"=>="image")
);
$dgrid->setModes($modes);
Set "nowrap" attribute for all columns in the datagrid.
## *** set nowrap attribute for all columns
$wrap = "nowrap";
$dgrid->setColumnsNoWrap($wrap);
Set CSS parameters for the datagrid. If you want to use embedded css class - define $css_type as "embedded" and $css_class as you wish. If you use external file of CSS styles - you define $css_type as "file" and $css_class as full path to your file. For example: $css_class = "../css/datagrid_style.css". Embedded CSS styles: "default", "gray", "like adwords" and "salomon".
## *** set CSS class for datagrid:
$css_class = "default";
$css_type = "embedded";
$dgrid->setCssClass($css_class, $css_type);
To be continued...
Step 3.
+---------------------------------------------------------------------------+
| Printing & Exporting Settings:
+---------------------------------------------------------------------------+
Set printing as true, if you want to allow this option
## *** set printing option: true(default) or false
$printing_option = true;
$dgrid->allowPrinting($printing_option);
Set exporting as true, if you want to allow this option
## *** set exporting option: true(default) or false
$exporting_option = true;
$dgrid->allowExporting($exporting_option);
Step 4.
+---------------------------------------------------------------------------+
| Sorting & Paging Settings:
+---------------------------------------------------------------------------+
Set sorting option as true, if you want to allow sorting on columns
## *** set sorting option: true(default) or false
$$sorting_option = true;
$dgrid->allowSorting($$sorting_option);
Set paging option as true, if you want to allow paging on datagrid
## *** set paging option: true(default) or false
$paging_option = true;
$dgrid->allowPaging($paging_option);
Set aditional paging settings. $bottom_paging or $top_paging are defines both (top and bottom) paging behaviour. We have thee part of paging line: results, pages and page_size dropdownbox. You need to set parameters for each of them. If you don't want to show any of them - leave it empty (Ex.: $bottom_paging = array()). If you want to define your own dropdown box with page sizes - you can make it in $pages_array array - see example below. Also you need to define default page size in $default_page_size variable.
## *** set paging settings
$bottom_paging = array("results"=>true, "results_align"=>"left", "pages"=>true, "pages_align"=>"center", "page_size"=>true, "page_size_align"=>"right");
$top_paging = array("results"=>true, "results_align"=>"left", "pages"=>true, "pages_align"=>"center", "page_size"=>true, "page_size_align"=>"right");
$pages_array = array(10, 25, 50, 100, 250, 500, 1000);
$default_page_size = 10;
$dgrid->setPagingSettings($bottom_paging, $top_paging, $pages_array, $default_page_size);
Step 5.
+---------------------------------------------------------------------------+
| 5. Filter Settings:
+---------------------------------------------------------------------------+
If you want to allow filtering mode, set $filtering_option as true.
## *** set filtering option: true or false(default)
$filtering_option = true;
$dgrid->allowFiltering($filtering_option);
To be continued...
Step 5.
+---------------------------------------------------------------------------+
| 6. View Mode Settings:
+---------------------------------------------------------------------------+
This method sets up columns, that will be viewable.
"header"=>"..." - name of the column header
"type"=>"..." - type of column: label, image, linktoview, link (http://, mailto:) or password
"align"=>"..." - alignment of the column data (left or right)
"wrap"=>"..." - wraping of the column data (wrap or nowrap)
"text_length"=>"..." - viewable text length (any number, "-1" - don't truncate )
"case"=>"..." - text case (normal or upper or lower)
## *** set columns in view mode
$vm_colimns = array(
"FieldName_1"=>array("header"=>"Name_A", "type"=>"label", "align"=>"left", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "case"=>"normal|upper|lower"),
"FieldName_2"=>array("header"=>"Name_B", "type"=>"image", "align"=>"left", "wrap"=>"wrap|nowrap", "text_length"=>'-1', "case"=>"normal|upper|lower"),
"FieldName_3"=>array("header"=>"Name_C", "type"=>"linktoview", "align"=>"left", "wrap"=>"wrap|nowrap", "text_length"=>'-1', "case"=>"normal|upper|lower"),
"FieldName_4"=>array("header"=>"Name_D", "type"=>"link", "align"=>"left", "wrap"=>"wrap|nowrap", "href"=>"www.yahoo.com", "target"=>"_new", "text_length"=>"-1", "case"=>"normal|upper|lower"),
"FieldName_5"=>array("header"=>"Name_E", "type"=>"link", "align"=>"left", "wrap"=>"wrap|nowrap", "field"=>"field_name", "prefix"=>"http://", "target"=>"_new", "text_length"=>"-1", "case"=>"normal|upper|lower"),
"FieldName_6"=>array("header"=>"Name_F", "type"=>"password", "align"=>"left", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "case"=>"normal|upper|lower")
);
$dgrid->setColumnsInViewMode($vm_colimns);
To be continued...
Subscribe to:
Posts (Atom)