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

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


?>

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.

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.