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.

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

##
########################################
?>

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 :)