Location: PHPKode > scripts > PHP DataGrid > docs/getting_started.htm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<html lang=en dir=ltr xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Getting Started - DataGrid Wiki</title>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta content="Getting Started" name=keywords><LINK href="/favicon.ico" 
rel="shortcut icon"><LINK title="Creative Commons" 
href="/getting_started.htm?title=Getting_Started&amp;action=creativecommons" 
type=application/rdf+xml rel=meta>
<link href="http://www.gnu.org/copyleft/fdl.html" rel=copyright>
<style type=text/css media=screen,projection>@import url( inc/main.css?7 );</style>
<link media=print href="inc/commonPrint.css" 
type=text/css rel=stylesheet><!--[if lt IE 5.5000]><style type="text/css">@import "inc/IE50Fixes.css";</style><![endif]--><!--[if IE 5.5000]><style type="text/css">@import "inc/IE55Fixes.css";</style><![endif]--><!--[if IE 6]>
<STYLE type=text/css>@import url( inc/IE60Fixes.css );
</STYLE>
<![endif]--><!--[if IE 7]><style type="text/css">@import "inc/IE70Fixes.css?1";</style><![endif]--><!--[if lt IE 7]>
<SCRIPT src="inc/IEFixes.js" 
type=text/javascript></SCRIPT>

<META http-equiv=imagetoolbar content=no><![endif]-->
<script type=text/javascript>var skin = 'monobook';var stylepath = '/dgwiki/skins';</script>
<script src="inc/wikibits.js" type=text/javascript><!-- wikibits js --></script>


<!-- Head Scripts -->
<meta content="MSHTML 6.00.2800.1561" name=GENERATOR></head>
<body class="ns-0 ltr">
<div id=globalWrapper>
<div id=column-content>
<div id=content><a id=top name=top></a>
<H1 class=firstHeading>Getting Started (find latest version <a href="http://phpbuilder.awardspace.com/dgwiki/index.php?title=Getting_Started">here</a>)</H1>
<div id=bodyContent>
<H3 id=siteSub>From DataGrid Wiki</h3>
<div id=contentSub></div>
<div id=jump-to-nav>Jump to: <a 
href="getting_started.htm?title=Getting_Started#column-one">navigation</a>, 
<a 
href="getting_started.htm?title=Getting_Started#searchInput">search</a></div><!-- start content -->
<p>Getting Started (for version 4.0.0 or above) </p>
<TABLE class=toc id=toc summary=Contents>
  <TBODY>
  <TR>
    <TD>
      <div id=toctitle>
      <h2>Contents</h2></div>
      <UL>
        <LI class=toclevel-1><a 
        href="getting_started.htm?title=Getting_Started#Common_Notices"><SPAN 
        class=tocnumber>1</SPAN> <SPAN class=toctext>Common Notices</SPAN></a> 
        <UL>
          <LI class=toclevel-2><a 
          href="getting_started.htm?title=Getting_Started#Syntax."><SPAN 
          class=tocnumber>1.1</SPAN> <SPAN class=toctext>Syntax.</SPAN></a> 
          <LI class=toclevel-2><a 
          href="getting_started.htm?title=Getting_Started#Common_notes."><SPAN 
          class=tocnumber>1.2</SPAN> <SPAN class=toctext>Common 
          notes.</SPAN></a> </LI></UL>
        <LI class=toclevel-1><a 
        href="getting_started.htm?title=Getting_Started#Getting_Started"><SPAN 
        class=tocnumber>2</SPAN> <SPAN class=toctext>Getting Started</SPAN></a> 
        <UL>
          <LI class=toclevel-2><a 
          href="getting_started.htm?title=Getting_Started#Step_1._Creating_.26_Calling."><SPAN 
          class=tocnumber>2.1</SPAN> <SPAN class=toctext>Step 1. Creating &amp; 
          Calling.</SPAN></a> 
          <LI class=toclevel-2><a 
          href="getting_started.htm?title=Getting_Started#Step_2._General_Settings."><SPAN 
          class=tocnumber>2.2</SPAN> <SPAN class=toctext>Step 2. General 
          Settings.</SPAN></a> 
          <LI class=toclevel-2><a 
          href="getting_started.htm?title=Getting_Started#Step_3._Printing_.26_Exporting_Settings."><SPAN 
          class=tocnumber>2.3</SPAN> <SPAN class=toctext>Step 3. Printing &amp; 
          Exporting Settings.</SPAN></a> 
          <LI class=toclevel-2><a 
          href="getting_started.htm?title=Getting_Started#Step_4._Sorting_.26_Paging_Settings."><SPAN 
          class=tocnumber>2.4</SPAN> <SPAN class=toctext>Step 4. Sorting &amp; 
          Paging Settings.</SPAN></a> 
          <LI class=toclevel-2><a 
          href="getting_started.htm?title=Getting_Started#Step_5._Filter_.28search.29_Settings."><SPAN 
          class=tocnumber>2.5</SPAN> <SPAN class=toctext>Step 5. Filter (search) 
          Settings.</SPAN></a> 
          <LI class=toclevel-2><a 
          href="getting_started.htm?title=Getting_Started#Step_6._View_Mode_Settings."><SPAN 
          class=tocnumber>2.6</SPAN> <SPAN class=toctext>Step 6. View Mode 
          Settings.</SPAN></a> 
          <LI class=toclevel-2><a 
          href="getting_started.htm?title=Getting_Started#Step_7._Add.2FEdit.2FDetails_Mode_Settings."><SPAN 
          class=tocnumber>2.7</SPAN> <SPAN class=toctext>Step 7. 
          Add/Edit/Details Mode Settings.</SPAN></a> 
          <LI class=toclevel-2><a 
          href="getting_started.htm?title=Getting_Started#Step_8._Bind_the_DataGrid."><SPAN 
          class=tocnumber>2.8</SPAN> <SPAN class=toctext>Step 8. Bind the 
          DataGrid.</SPAN></a> </LI></UL>
        <LI class=toclevel-1><a href="getting_started.htm?title=Getting_Started#Not_documented_features_and_functions."><SPAN class=tocnumber>3</SPAN> <SPAN class=toctext>Not documented features and functions.</SPAN></a> 
        <UL>
          <LI class=toclevel-2><a 
          href="getting_started.htm?title=Getting_Started#Properties"><SPAN 
          class=tocnumber>3.1</SPAN> <SPAN class=toctext>Properties</SPAN></a> 
          <LI class=toclevel-2><a 
          href="getting_started.htm?title=Getting_Started#Methods"><SPAN 
          class=tocnumber>3.2</SPAN> <SPAN class=toctext>Methods</SPAN></a> 
          <LI class=toclevel-2><a 
          href="getting_started.htm?title=Getting_Started#Features"><SPAN 
          class=tocnumber>3.3</SPAN> <SPAN class=toctext>Features</SPAN></a> 
          </LI></UL></LI></UL></TD></TR></TBODY></TABLE>
<SCRIPT type=text/javascript> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </SCRIPT>

<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a 
title="Edit section: Common Notices" 
href="getting_started.htm?title=Getting_Started&amp;action=edit&amp;section=1">edit</a>]</div><a name=Common_Notices></a>
<h2><b>Common Notices</b></h2>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: Syntax." href="getting_started.htm?title=Getting_Started&amp;action=edit&amp;section=2">edit</a>]</div><a name=Syntax.></a>
<h3><b>Syntax.</b></h3>
<p>We use </p>
<p><b>##</b> as comments<br /><b>//</b> as lines, that must be 
uncommented<br /><b>///</b> as lines, that may be uncommented (optional)<br /></p>
<p><br /></p>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: Common notes." href="getting_started.htm?title=Getting_Started&amp;action=edit&amp;section=3">edit</a>]</div><a name=Common_notes.></a>
<h3><b>Common notes.</b></h3>
<p><font color=darkred><b>Please, use a <i>$debug_mode = true;</i> before you say "Why Nothing Works&nbsp;?!" </b><br /></font></p>
<p><font color=darkred><b>From version 4.2.4 only PHP5 is supported! </b><br /></font></p>
<p><font color=darkred><b>Do not put DataGrid code into another HTML form: &lt;form&gt;...&lt;/form&gt; </b><br /></font></p>
<p><br /></p>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: Getting Started" href="getting_started.htm?title=Getting_Started&amp;action=edit&amp;section=4">edit</a>]</div><a name=Getting_Started></a>
<h2><b>Getting Started</b></h2>
<p>(for version 4.0.0 or above) </p><!--
<p>This article in other languages: </p><pre> <a title="Guía de usuario" href="getting_started.htm?title=Gu%C3%ADa_de_usuario">Spanish</a>
</pre>-->
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: Step 1. Creating &amp; Calling." href="getting_started.htm?title=Getting_Started&amp;action=edit&amp;section=5">edit</a>]</div>
<a name=Step_1._Creating_.26_Calling.></a>
<h3><b>Step 1. Creating &amp; Calling.</b></h3>
<p>+---------------------------------------------------------------------------+<br />| 
Creating &amp; Calling: 
<br />+---------------------------------------------------------------------------+<br /></p>
<p>Be sure you write here a right relative (virtual) path to the 
<b>datagrid.class.php</b> file and <b>pear</b> directory (relatively to the 
current file). </p>
<p><u><b>RELATIVE PATH ONLY</b></u> </p><pre><font color=darkblue><b>
define ("DATAGRID_DIR", "");    </b></font><font color=green>/* Ex.: "datagrid/" */</font><font color=darkblue><b>
define ("PEAR_DIR", "pear/");   </b></font><font color=green>/* Ex.: "datagrid/pear/" */</font>
<font color=darkblue><b>
require_once(DATAGRID_DIR.'datagrid.class.php');
require_once(PEAR_DIR.'PEAR.php');
require_once(PEAR_DIR.'DB.php');
</b></font>
</pre>
<p>Put valid values into these variables. Be sure, you use a prefix if you need 
it. </p><pre><font color=green>
##  *** creating variables that we need for database connection </font>
<font color=darkblue><b>
$DB_USER='name';       </b></font><font color=green>/* usually like this: prefix_name           */</font><font color=darkblue><b>
$DB_PASS=' ';          </b></font><font color=green>/* must be already enscrypted (recommended) */</font><font color=darkblue><b>
$DB_HOST='localhost';  </b></font><font color=green>/* usually localhost                        */</font><font color=darkblue><b>
$DB_NAME='dbName';     </b></font><font color=green>/* usually like this: prefix_dbName         */</font>
</pre>
<p>First of all, we need to be connected to our database. </p><pre><font color=darkblue><b>ob_start();</b></font>
<font color=green> 
## *** (example of ODBC connection string)
## *** $result_conn = $db_conn->connect(DB::parseDSN('odbc://root:hide@address.com'));
## *** (example of Oracle connection string)
## *** $result_conn = $db_conn->connect(DB::parseDSN('oci8://root:hide@address.com:1521/mydatabase)); 
## *** (example of PostgreSQL connection string)
## *** $result_conn = $db_conn->connect(DB::parseDSN('pgsql://root:hide@address.com/mydatabase)); 
## === (Examples of connections to other db types see in "docs/pear/" folder)</font>
<font color=darkblue><b>
$db_conn =&amp; DB::factory('mysql'); 
$result_conn = 
   $db_conn->connect(DB::parseDSN('mysql://'.$DB_USER.':'.$DB_PASS.'@'.$DB_HOST.'/'.$DB_NAME));
if(DB::isError($result_conn)){ 
   die($result_conn->getMessage()); 
}</b></font>
</pre>
<p>Now you have to prepare the 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 them to be shown, because the DataGrid class works with only on fields that 
you placed in SELECT statement. </p>
<p><STRONG>Don't add here ORDER BY, LIMIT words or&nbsp;; at the end of the 
statement.</STRONG> </p><pre><font color=green>
##  *** put a primary key on the first place </font>
<font color=darkblue><b>
$sql = "SELECT primary_key, filed_1, filed_2 ... FROM tableName ";
</b></font>
</pre>
<p>Creating the a new class instance and linking the DataGrid class to our 
database. 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 same page). </p><pre><font color=green>##  *** set needed options and create a new class instance </font><br />
<font color=green>// display SQL statements while processing</font> 
<font color=darkblue><b>$debug_mode = false;</b></font>
<font color=green>// display system messages on a screen</font>     
<font color=darkblue><b>$messaging = true;</b></font>
<font color=green>// prevent overlays - must be started with a letter</font>
<font color=darkblue><b>$unique_prefix = "abc_";</b></font>
<font color=darkblue><b>
$dgrid = new DataGrid($debug_mode, $messaging, $unique_prefix, DATAGRID_DIR);
</b></font>
</pre>
<p>Now we need to set data source to the DataGrid. We may define default columns 
ordering, by writing an apropriate field in <b>$default_order_field</b> (you can 
write some fields, separated by commas) and a sorting type in 
<b>$default_order_type</b> (they also may be written with commas).<br />Example: 
<br /><b>$default_order_field = "Region, CountryID";</b><br /><b>$default_order_type 
= "ASC, DESC";</b> </p><pre><font color=green>##  *** set data source with needed options</font><br />
<font color=green>// make default(first) ordering by this field</font>
<font color=darkblue><b>$default_order_field = "field_name_1 [, field_name_2...]";</b></font>
<font color=green>// default field order type</font>
<font color=darkblue><b>$default_order_type = "ASC|DESC [, ASC|DESC...]";</b></font>
<font color=darkblue><b>
$dgrid->DataSource($db_conn, $sql, $default_order_field, $default_order_type);	    
</b></font>
</pre>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a 
title="Edit section: Step 2. General Settings." 
href="getting_started.htm?title=Getting_Started&amp;action=edit&amp;section=6">edit</a>]</div><a 
name=Step_2._General_Settings.></a>
<h3><b>Step 2. General Settings.</b></h3>
<p>+---------------------------------------------------------------------------+<br />| 
General Settings: 
<br />+---------------------------------------------------------------------------+<br /></p>
<p>If you want to use a local language (not English) - you have to set the right 
encoding. <STRONG>The database, tables and appropriate fields in your database 
must be created with the same CHARACTER SET and COLLATE too.</STRONG> Also you 
need to define in your file: <STRONG>header('Content-type: text/html; 
charset=XXXX');</STRONG> where xxxx ISO-8859-1 or UTF-8 or whatever you 
have.<br />Example: CHARSET=utf8 COLLATE=utf8_unicode_ci<br />Example: <meta 
http-equiv=Content-Type content="text/html; charset=UTF-8"> </p>
<pre>
<font color=green>##  *** set encoding (default - utf8)</font>
<font color=darkblue><b>
$dg_encoding = "utf8"; 
$dgrid->SetEncoding($dg_encoding);
</b></font>
</pre>

<p>Set interface language for DatagGrid (en - default). All supported languages 
are listed under commented lines. </p>
<pre><font color=green>
##  *** set interface language (default - English)
##  *** (en) - English     (de) - German     (se) - Swedish   (hr) - Bosnian/Croatian
##  *** (hu) - Hungarian   (es) - Espanol    (ca) - Catala    (fr) - Francais
##  *** (nl) - Netherlands/"Vlaams"(Flemish) (it) - Italiano  (pl) - Polish
##  *** (ch) - Chinese     (sr) - Serbian    (bg) - Bulgarian (pb) - Brazilian Portuguese
##  *** (ar) - Arabic      (tr) - Turkish    (cz) - Czech
</font>
<font color=darkblue><b>
$dg_language = "en";  
$dgrid->SetInterfaceLang($dg_language);
</b></font>
</pre>

<p>Option for some right-to-left languages (Hebrew, Arabic etc.) </p><pre><font color=green>##  *** set direction: "ltr" or "rtl" (default - ltr)</font>
<font color=darkblue><b>
$direction = "ltr";
$dgrid->SetDirection($direction);
</b></font>
</pre>
<p>Set layouts for datagrid in view or edit mode and for the filtering block 
</p><pre><font color=green>##  *** set layouts: 0 - tabular(horizontal) - default, 1 - columnar(vertical)</font>
<font color=darkblue><b>
$layouts = array("view"=>0, "edit"=>1, "filter"=>1); 
$dgrid->SetLayouts($layouts);
</b></font>
</pre>
<p>Set various modes for datagrid. <b>true</b> - allow the operation in this 
mode("view" or "edit"), <b>false</b> - don't allow. <b>type</b> - a type of 
command button (link, html button or image). <b>byFieldValue</b> - 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 this parameter empty: <b>"byFieldValue"=>""</b> </p><pre><font color=green>##  *** set modes for operations ("type" = "link|button|image"),
##  *** ("byFieldValue" - make the field as a link to edit mode page)
##  *** ("show_add_button"=>"inside|outside" - draw Add button inside or outside of DataGrid)</font>
<font color=darkblue><b>
$modes = array(
  "add"     =>array("view"=>true, "edit"=>false, "type"=>"link", "show_add_button"=>"inside|outside"),
  "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);
</b></font>
</pre>
<p>Set scrolling settings and parameters for DataGrid. If you want the DataGrid 
will be displayed with scrolling, allow this option by the next commands. </p><pre><font color=green><b>
##  *** allow scrolling on datagrid</b></font>
<font color=darkblue><b>
$scrolling_option = false;
$dgrid->AllowScrollingSettings($scrolling_option);  
</b></font>
<font color=green><b>
##  *** set scrolling settings (optional)</b></font><font color=darkblue><b>
$scrolling_width = "90%";
$scrolling_height = "100%";
$dgrid->SetScrollingSettings($scrolling_width, $scrolling_height);
</b></font>
</pre>
<p>If you want to allow multirow operations for DataGrid, set 
<b>$multirow_option = true;</b> </p><pre><font color=green><b>##  *** allow mulirow operations</b></font>
<font color=darkblue><b>
$multirow_option = true;
$dgrid->AllowMultirowOperations($multirow_option);
</b></font>
</pre>
<p>You can work with embedded multi-row operations: delete/details or define 
your own operation, like in example below. Number of operations, that you may 
define - is not limited. </p><pre><font color=darkblue><b>
$multirow_operations = array(
  "delete"  => array("view"=>true),
  "details" => array("view"=>true),
  "my_operation_name" => 
     array("view"=>true, 
           "flag_name"=>"my_flag_name", 
           "flag_value"=>"my_flag_value", 
           "tooltip"=>"Do something with selected", 
           "image"=>"image.gif")
);
$dgrid->SetMultirowOperations($multirow_operations);  
</b></font>
</pre>
<p>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 an 
external file of CSS styles - you define $css_type as "file" and $css_class as 
the full path to your file. </p>
<p><b>For example:$css_class = "css/style.css".<br />Embedded CSS styles: "default", "blue", "gray", "green" and "pink".</b> </p><pre><font color=green><b>
##  *** set CSS class for datagrid:
##  *** "default" or "blue" or "gray" or "green" or your css file relative path with name
</b></font>
<font color=darkblue><b>$css_class = "default";</b></font>
<font color=green><b>
## "embedded" - use embedded classes, "file" - link to external css file (relative path)
</b></font><font color=darkblue><b>
$css_type = "embedded"; 
$dgrid->SetCssClass($css_class, $css_type);
</b></font>
</pre>
<p>Set variables that you use to get access to your page or have passed from the 
previous page/s. </p><pre><font color=green><b>
##  *** set variables that used to get access to the page
##  *** (like: my_page.php?act=34&amp;id=56 etc.)  </b></font>
<font color=darkblue><b>
$http_get_vars = array("act", "id");
$dgrid->SetHttpGetVars($http_get_vars);
</b></font>
</pre>
<p>If you want to use some PHP DataGrid on your page, you need to define other 
datagrids uniquie prefixes to allow each datagrid to detect others. You need to 
define in which mode (view/edit/details) the current datagrid will recognize 
others. </p><pre><font color=green><b>
##  *** set another datagrid/s unique prefixes (if you use few datagrids on one page)
##  *** format (in wich mode to allow processing of another datagrids)
##  *** array("unique_prefix"=>array ("view"=>true|false, "edit"=>true|false, "details"=>true|false), [,...]);</b></font>
<font color=darkblue><b>
$anotherDatagrids = array("abcd_"=>array("view"=>true, "edit"=>true, "details"=>true));
$dgrid->SetAnotherDatagrids($anotherDatagrids);  
</b></font>
</pre>
<p>Set datagrid title (caption). </p><pre><font color=green><b>
##  *** set DataGrid Caption</b></font>
<font color=darkblue><b>
$dg_caption = "My Favorite Lovely PHP DataGrid";
$dgrid->SetCaption($dg_caption);
</b></font>
</pre>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a 
title="Edit section: Step 3. Printing &amp; Exporting Settings." 
href="getting_started.htm?title=Getting_Started&amp;action=edit&amp;section=7">edit</a>]</div><a 
name=Step_3._Printing_.26_Exporting_Settings.></a>
<h3><b>Step 3. Printing &amp; Exporting Settings.</b></h3>
<p>+---------------------------------------------------------------------------+<br />| 
Printing &amp; Exporting Settings: 
<br />+---------------------------------------------------------------------------+<br /></p>
<p>If you want to allow users to view printer-priendly pages and print them - 
set printing as true. </p><pre><font color=green><b>
##  *** set printing option: true(default) or false </b></font>
<font color=darkblue><b>
$printing_option = true;
$dgrid->AllowPrinting($printing_option); </b></font>
</pre>
<p>If you want to allow users to export datagrid data - set exporting as true and define exporting directory. 
</p><pre><font color=green><b>
##  *** set exporting option: true(default) or false and relative (virtual) path
##  *** to export directory (relatively to datagrid.class.php file).
##  *** Ex.: "" - if we use current datagrid folder
</b></font>
<font color=darkblue><b>
$exporting_option = true;
$exporting_directory = ""; 
$dgrid->AllowExporting($exporting_option, $exporting_directory);
$exporting_types = array("excel"=>"true", "pdf"=>"true", "xml"=>"true");
$dgrid->AllowExportingTypes($exporting_types);
</b></font>
</pre>

<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: Step 4. Sorting & Paging Settings." 
href="getting_started.htm?title=Getting_Started&amp;action=edit&amp;section=8">edit</a>]</div>
<a name=Step_4._Sorting_.26_Paging_Settings.></a>
<h3><b>Step 4. Sorting &amp; Paging Settings.</b></h3>
<p>+---------------------------------------------------------------------------+<br />| 
Sorting &amp; Paging Settings: 
<br />+---------------------------------------------------------------------------+<br /></p>
<p>Set sorting option as true, if you want to allow sorting on columns. </p><pre><font color=green><b>
##  *** set sorting option: true(default) or false </b></font>
<font color=darkblue><b>
$sorting_option = true;
$dgrid->AllowSorting($sorting_option);
</b></font>
</pre>
<p>Set paging option as true, if you want to allow paging on datagrid. If you 
want to add a column with rows numeration - set $rows_numeration as true. </p><pre><font color=green><b>
##  *** set paging option: true(default) or false </b></font>
<font color=darkblue><b>
$paging_option = true;
$rows_numeration = false;
$numeration_sign = "N #";
$dgrid->AllowPaging($paging_option, $rows_numeration, $numeration_sign);
</b></font>
</pre>
<p>Set aditional paging settings. <br /><b>$top_paging</b> or 
<b>$bottom_paging</b> - both define paging (top and bottom) behaviour. We have 
three parts of the paging line (left, center, right): <I>results</I>, 
<I>pages</I> and <I>page size</I> dropdownbox. You need to set parameters for 
each of them. If you don't want to show any of them or all of them - leave it 
empty Ex.: <b>$bottom_paging = array()</b> or <b>$bottom_paging = 
array("results"=>true, "results_align"=>"left");</b>. <br />If you want to 
define your own dropdown box with page sizes - you can make it in 
<b>$pages_array array</b> - see example below or leave it empty. Also you can 
define default page size in <b>$default_page_size</b> variable. </p><pre><font color=green><b>
##  *** set paging settings </b></font>
<font color=darkblue><b>
$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"=>"10", "25"=>"25", "50"=>"50", "100"=>"100", "250"=>"250");
$default_page_size = 10;
$paging_arrows = array("first"=>"|&lt;&lt;", "previous"=>"&lt;&lt;", "next"=>"&gt;&gt;", "last"=>"&gt;&gt;|");
$dgrid->SetPagingSettings($bottom_paging, $top_paging, $pages_array, $default_page_size);
</b></font>
</pre>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a 
title="Edit section: Step 5. Filter (search) Settings." 
href="getting_started.htm?title=Getting_Started&amp;action=edit&amp;section=9">edit</a>]</div><a 
name=Step_5._Filter_.28search.29_Settings.></a>
<h3><b>Step 5. Filter (search) Settings.</b></h3>
<p>+---------------------------------------------------------------------------+<br />| 
Filter Settings: 
<br />+---------------------------------------------------------------------------+<br /></p>
<p>If you want to allow a filtering mode, set $filtering_option as true. </p><pre><font color=green><b>
##  *** set filtering option: true or false(default)
##  *** tips: use "," (comma) if you want to make search by some words, for ex.: hello, bye, hi</b></font>
<font color=darkblue><b>
$filtering_option = true;
$dgrid->AllowFiltering($filtering_option);
</b></font>
</pre>
<p>Set aditional filtering settings. </p>
<p><b>"Caption_1/2/3/.../n"=></b> - caption for the filtering 
field<br /><b>"table"=>"tableName_1/2/3/.../n"</b><br /><b>"field"=>"fieldName_1/2/3/.../n"</b> 
- table and field we want to 
filter<br /><b>"source"=>"self"|$fill_from_array</b> - take values for 
filtering field (dropdown list) from the specific array or not<br />Example: </p><pre><font color=darkblue><b>
$fill_from_array = array("0"=>"No", "1"=>"Yes");
</b></font>
</pre>
<p>
<b>"operator"=>false|true</b> - draw comparison operators dropdown list or not<br />
<b>"order"=>"ASC|DESC"</b> - dropdown list values order (optional)<br />
<b>"type"=>"textbox|dropdownlist|calendar"</b> - view type of filtering filed (textbox - default)<br />
<b>"autocomplete"=>"false|true"</b> - AJAX autocomplete function (for textbox only)<br />
<b>"handler"=>"modules/autosuggest/test.php"</b> - script that handels autocomplete (for autocomplete only)<br />
<b>"maxresults"=>"12"</b> - number of results, that autocomple function returns (for autocomplete only)<br />
<b>"shownoresults"=>"false|true"</b> - show or not "No Results" box (for autocomplete only)<br />
<b>"case_sensitive"=>false|true</b> - whether filtering is case sensitive<br />
<b>"comparison_type"=>"string|numeric|binary"</b> - filtering comparison type<br />
<b>"on_js_event"=>""</b> - add here client side javascript function or code<br />
<b>"width"=>""</b> - define a width of filtering field<br />
<b>"show"=>""</b> - "show"=>"CONCAT(field1,','field2) as field3" or "show"=>"'link' as field3" or "show"=>"field_name as my_field_name"<br />
<b>"condition"=>""</b> - some condition. Ex.: TableName_1.FieldName > 'a' AND TableName_1.FieldName < 'c' <br /><br />
</p><pre><font color=green><b>
##  *** set aditional filtering settings
</b></font>
<font color=darkblue><b>
$filtering_fields = array(
    "Caption_1"=>array(
        "type"=>"textbox",
        "table"=>"tableName_1",
        "field"=>"fieldName_1|,fieldName_2",
        "show_operator"=>false|true,
        "default_operator"=>"=|<|>|like|%like|like%|%like%|not like",
        "case_sensitive"=>false|true,
        "comparison_type"=>"string|numeric|binary",
        "width"=>"",
        "on_js_event"=>""),
    "Caption_2"=>array(
        "type"=>"textbox",
        "autocomplete"=>"false|true",
        "handler"=>"modules/autosuggest/test.php",
        "maxresults"=>"12",
        "shownoresults"=>"false|true",
        "table"=>"tableName_1",
        "field"=>"fieldName_1|,fieldName_2",
        "show_operator"=>false|true,
        "default_operator"=>"=|<|>|like|%like|like%|%like%|not like",
        "case_sensitive"=>false|true,
        "comparison_type"=>"string|numeric|binary", 
        "width"=>"",
        "on_js_event"=>""),
    "Caption_3"=>array(
        "type"=>"dropdownlist",
        "order"=>"ASC|DESC",
        "table"=>"tableName_2",
        "field"=>"fieldName_2",
        "source"=>"self"|$fill_from_array,
        "show_operator"=>false|true,
        "default_operator"=>"=|<|>|like|%like|like%|%like%|not like",
        "case_sensitive"=>false|true,
        "comparison_type"=>"string|numeric|binary",
        "width"=>"",
        "on_js_event"=>""
        "show"=>"",
        "condition"=>""),
    "Caption_4"=>array(
        "type"=>"calendar",
        "table"=>"tableName_3",
        "field"=>"fieldName_3",
        "show_operator"=>false|true,
        "default_operator"=>"=|<|>|like|%like|like%|%like%|not like",
        "case_sensitive"=>false|true,
        "comparison_type"=>"string|numeric|binary",
        "width"=>"",
        "on_js_event"=>"")
);
$dgrid->SetFieldsFiltering($filtering_fields);
</b></font>
</pre>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a 
title="Edit section: Step 6. View Mode Settings." 
href="getting_started.htm?title=Getting_Started&amp;action=edit&amp;section=10">edit</a>]</div><a 
name=Step_6._View_Mode_Settings.></a>
<h3><b>Step 6. View Mode Settings.</b></h3>
<p>+---------------------------------------------------------------------------+<br />| 
View Mode Settings: 
<br />+---------------------------------------------------------------------------+<br /></p>
<p>Set some properties for view mode table </p><pre><font color=green><b>
##  *** set table properties</b></font>
<font color=darkblue><b>
$vm_table_properties = array("width"=>"90%");
$dgrid->SetViewModeTableProperties($vm_table_properties);  
</b></font>
</pre>
<p>This method sets up columns, that will be viewable. </p>
<p>For all types:<br /><b>"header"=>"..."</b> - name of the column's 
header<br /><b>"type"=>"..."</b> - type of the column. <br />Possible values: 
label, image, linktoview, linktoedit, linktodelete, link (<a class="external free" 
title=http:// href="http:///" rel=nofollow>http://</a>, <a class="external free" 
title=mailto href="http://phpbuilder.awardspace.com/dgwiki/mailto" 
rel=nofollow>mailto</a>:, ftp:// ...), password or 
barchart<br /><b>"align"=>"..."</b> - horizontal alignment of the column's 
content (left, center or right)<br />
<b>"sort_type"=>"string|numeric"</b> - type of column sorting<br />
<b>"width"=>"..."</b> - width of the column in pixels or in percents<br />
<b>"wrap"=>"..."</b> - wraping of the column data (wrap or nowrap)<br />
<b>"text_length"=>"..."</b> - viewable length of the text in characters (any integer number - truncate after this number of characters, "-1" - don't truncate (view a full text))<br />
<b>"case"=>"..."</b> - text case (normal, upper, lower or camel)<br />
<b>"summarize"=>...</b> - summarize values in this column (true or false)<br />
<b>"on_js_event"=>"..."</b> - javascript code or js function on some event. Example: onClick(alert('Clicked!')) <br /><br /></p>
<p>For the "link" 
type:<br /><b>"field_key"=>"field_name_0"|"field_key_1"=>"field_name_1"|...,</b> 
- field for href parameter in <a 
href="...field_key_x..."><br /><b>"field_data"=>"...",</b> - field for <a 
href="">field_data</a><br /><b>"href"=>"..."</b> - href parameter, 
{0}/{1}/... will be changed on "field_key_0/1/..." 
value<br /><b>"target"=>"..."</b> - target parameter<br /><br /></p>
<p>For the "image" type:<br /><b>"target_path"=>"..."</b> - relative path to 
image<br /><b>"default"=>"..."</b> - default image 
name<br /><b>"image_width"=>"..."</b> - viewing width of 
image<br /><b>"image_height"=>"..."</b> - viewing height of image<br />
<b>"magnify"=>"true|false"</b> - magnify image on mouse over
<br /><br /></p>
<p>For the "money" type:<br />
<b>"sign"=>"$"</b> - money sign<br />
<b>"decimal_places"=>"2"</b> - number of decimal places<br />
<b>"dec_separator"=>"."</b> - sign for separation of decimal digits<br />
<b>"thousands_separator"=>"."</b> - sign for separation of thousands digits<br /><br />
</p>
<p>For the "barchart" type:<br /><b>"field"=>"..."</b> - filed 
name<br /><b>"maximum_value"=>"..."</b> maximal value for the chart. Number 
rormat in SELECT SQL must be equal with number format in max_value.<br /><br /></p>
<p>For the "enum" type:<br /><b>"source"=>"..."</b> - source for enum type. Possible values: user's pre-defined array<br /><br /></p>
<pre><font color=green><b>
##  *** set columns in view mode
##  *** Ex.: "on_js_event"=>"onclick='alert(\"Yes!!!\");'"
</b></font>
<font color=darkblue><b>
$vm_colimns = array(
    "FieldName_1" => array("header"=>"Name_A", "type"=>"label",      "align"=>"left", "width"=>"X%|Xpx", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower|camel", "summarize"=>"false", "sort_type"=>"string|numeric", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
    "FieldName_2" => array("header"=>"Name_B", "type"=>"image",      "align"=>"left", "width"=>"X%|Xpx", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower|camel", "summarize"=>"false", "sort_type"=>"string|numeric", "sort_by"=>"", "visible"=>"true", "on_js_event"=>"", "target_path"=>"uploads/", "default"=>"default_image.ext", "image_width"=>"50px", "image_height"=>"30px", "magnify"=>"false"),
    "FieldName_3" => array("header"=>"Name_C", "type"=>"linktoview", "align"=>"left", "width"=>"X%|Xpx", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower|camel", "summarize"=>"false", "sort_type"=>"string|numeric", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
    "FieldName_4" => array("header"=>"Name_D", "type"=>"linktoedit", "align"=>"left", "width"=>"X%|Xpx", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower|camel", "summarize"=>"false", "sort_type"=>"string|numeric", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
    "FieldName_5" => array("header"=>"Name_E", "type"=>"linktodelete", "align"=>"left", "width"=>"X%|Xpx", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower|camel", "summarize"=>"false", "sort_type"=>"string|numeric", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
    "FieldName_6" => array("header"=>"Name_F", "type"=>"link",       "align"=>"left", "width"=>"X%|Xpx", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower|camel", "summarize"=>"false", "sort_type"=>"string|numeric", "sort_by"=>"", "visible"=>"true", "on_js_event"=>"", "field_key"=>"field_name_0"|"field_key_1"=>"field_name_1"|..., "field_data"=>"field_name_2", "rel"=>"", "title"=>"", "target"=>"_new", "href"=>"{0}"),
    "FieldName_7" => array("header"=>"Name_G", "type"=>"link",       "align"=>"left", "width"=>"X%|Xpx", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower|camel", "summarize"=>"false", "sort_type"=>"string|numeric", "sort_by"=>"", "visible"=>"true", "on_js_event"=>"", "field_key"=>"field_name_0"|"field_key_1"=>"field_name_1"|..., "field_data"=>"field_name_2", "rel"=>"", "title"=>"", "target"=>"_new", "href"=>"mailto:{0}"),
    "FieldName_8" => array("header"=>"Name_H", "type"=>"link",       "align"=>"left", "width"=>"X%|Xpx", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower|camel", "summarize"=>"false", "sort_type"=>"string|numeric", "sort_by"=>"", "visible"=>"true", "on_js_event"=>"", "field_key"=>"field_name_0"|"field_key_1"=>"field_name_1"|..., "field_data"=>"field_name_2", "rel"=>"", "title"=>"", "target"=>"_new", "href"=>"http://mydomain.com?act={0}&act={1}&code=ABC"),
    "FieldName_9" => array("header"=>"Name_I", "type"=>"money",      "align"=>"left", "width"=>"X%|Xpx", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower|camel", "summarize"=>"false", "sort_type"=>"string|numeric", "sort_by"=>"", "visible"=>"true", "on_js_event"=>"", "sign"=>"$", "decimal_places"=>"2", "dec_separator"=>".", "thousands_separator"=>","),
    "FieldName_10"=> array("header"=>"Name_J", "type"=>"password",   "align"=>"left", "width"=>"X%|Xpx", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower|camel", "summarize"=>"false", "sort_type"=>"string|numeric", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
    "FieldName_11"=> array("header"=>"Name_K", "type"=>"barchart",   "align"=>"left", "width"=>"X%|Xpx", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower|camel", "summarize"=>"false", "sort_type"=>"string|numeric", "sort_by"=>"", "visible"=>"true", "on_js_event"=>"", "field"=>"field_name", "maximum_value"=>"value"),
    "FieldName_12"=> array("header"=>"Name_L", "type"=>"enum",       "align"=>"left", "width"=>"X%|Xpx", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower|camel", "summarize"=>"false", "sort_type"=>"string|numeric", "sort_by"=>"", "visible"=>"true", "on_js_event"=>"", "source"=>$fill_from_array),
);
$dgrid->SetColumnsInViewMode($vm_colimns);
</b></font>
</pre>
<p><br />If you want to get auto-genereted columns - set 
<b>$auto_column_in_view_mode</b> as true. </p><pre><font color=green><b>
##  *** set auto-genereted columns in view mode
</b></font><font color=darkblue><b>
$auto_column_in_view_mode = false;
$dgrid->SetAutoColumnsInViewMode($auto_column_in_view_mode);
</b></font>
</pre>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a 
title="Edit section: Step 7. Add/Edit/Details Mode Settings." 
href="getting_started.htm?title=Getting_Started&amp;action=edit&amp;section=11">edit</a>]</div><a 
name=Step_7._Add.2FEdit.2FDetails_Mode_Settings.></a>
<h3><b>Step 7. Add/Edit/Details Mode Settings. </b></h3>
<p>+---------------------------------------------------------------------------+<br />| 
Add/Edit/Details Mode Settings: 
<br />+---------------------------------------------------------------------------+<br /></p>
<p>Set properties for edit mode table. </p><pre><font color=green><b>
##  *** set add/edit mode table properties
</b></font><font color=darkblue><b>
$em_table_properties = array("width"=>"70%");
$dgrid->SetEditModeTableProperties($em_table_properties);
</b></font>
</pre>
<p>Set properties for details mode table. </p><pre><font color=green><b>
##  *** set details mode table properties
</b></font><font color=darkblue><b>
$dm_table_properties = array("width"=>"70%");
$dgrid->SetDetailsModeTableProperties($dm_table_properties);
</b></font>
</pre>
<p>Set settings for add/edit/details modes </p><pre><font color=green><b>
##  ***  set settings for add/edit/details modes

// Table for adding and editing</b></font><font color=darkblue><b>
$table_name  = "table_name";</b></font>
<font color=green><b>
// Primary key for this table</b></font><font color=darkblue><b>
$primary_key = "primary_key";</b></font> 
<font color=green><b>
// Condition. Ex.: table_name.field = 'xxx'</b></font><font color=darkblue><b>
$condition = "";<br />
$dgrid->SetTableEdit($table_name, $primary_key, $condition);
</b></font>
</pre>
<p><br />This method sets up columns, that will be viewable. </p>
<p>For all types:<br /><b>"header"=>"..."</b> - name of the column's 
header<br /><b>"type"=>"..."</b> - type of the column. <br /></p><pre>Possible values: 
    textbox,          textarea, 
    label,            password,  
    print,            date(yyyy-mm-dd), 
    enum,             datedmy(dd-mm-yyyy), 
    image,            datetime(yyyy-mm-dd hh:mm:ss), 
    checkbox,         datetimedmy(dd-mm-yyyy hh:mm:ss),                  
    file,             link (<a class="external free" title=http:// href="http:///" rel=nofollow>http://</a>, <a class="external free" title=mailto href="http://phpbuilder.awardspace.com/dgwiki/mailto" rel=nofollow>mailto</a>:, ftp:// ...) 
    hidden,           delimiter            

</pre>
<p><b>"req_type"=>"..."</b> - field parameters:<br /></p><pre>first letter: 
    r - required,      s - simple (not required)
second letter: 
    t - text(including datetime), 
    n - numeric,       a - alphanumeric, 
    e - email,         f - float, 
    y - any,           l - login name, 
    z - zipcode,       p - password, 
    i - integer,       v - verified, 
    z - zip code       u - URL
third letter (optional): 
    for numbers: s - signed, u - unsigned, p - positive, n - negative
    for strings: u - upper,  l - lower,    n - normal,   y - any
</pre>
<p><b>"align"=>"..."</b> - field horizontal align<br /></p><pre>Possible values: 
    left, center, right
</pre>
<p><b>"width"=>"..."</b> - width of the field in 
pixels<br /><b>"title"=>"..."</b> - title (tooltip) of the 
field<br /><b>"readonly"=>"..."</b> - if the filed is readonly 
(false|true)<br /><b>"maxlength"=>"..."</b> - maximal size in characters of the 
field value<br /><b>"default"=>...</b> - default value for the field (for add 
mode only)<br /><b>"unique"=>...</b> - make or not (true|false) validation for 
unique values for this field<br /><b>"unique_condition"=>...</b> - validation 
for unique values for this field by the condition (ex.: field_1 > 1 OR 
field_2 = 99)<br /><b>"on_js_event"=>"..."</b> - javascript code or js function 
on some event. Example: onClick(alert('Clicked!')) <br /><br /></p>

<p>For the "link" 
type:<br /><b>"field_key"=>"field_name_0"|"field_key_1"=>"field_name_1"|...,</b> 
- field for href parameter in &lt;a 
href="...field_key_x..."><br /><b>"field_data"=>"...",</b> - field for &lt;a 
href="">field_data</a><br /><b>"href"=>"..."</b> - href parameter, 
{0}/{1}/... will be changed on "field_key_0/1/..." 
value<br /><b>"target"=>"..."</b> - target parameter<br /><br /></p>
<p>For the "image" type:<br />Make sure, that target_path directory has 777 
permissions<br /><b>"target_path"=>"..."</b> - relative (or full) path to 
image<br /><b>"file_name"=>"..."</b> - set new name for image or use an 
original file name<br /><b>"max_file_size"=>"..."</b> - maximal image size 
allowed. Ex.: 1000, 10K, 1.2M or 1G<br /><b>"image_width"=>"..."</b> - viewing 
width of image<br /><b>"image_height"=>"..."</b> - viewing height of 
image<br /><b>"magnify"=>"true|false"</b> - magnify image on mouse over<br /><br /></p>
<p>For the "file" type:<br />Make sure, that target_path directory has 777 
permissions<br /><b>"target_path"=>"..."</b> - relative (or full) path to 
file<br /><b>"file_name"=>"..."</b> - set new name for file use an original 
file name<br /><b>"max_file_size"=>"..."</b> - maximal image size allowed. Ex.: 
1000, 10K, 1.2M or 1G<br /></p>
<p>For the "checkbox" type:<br /><b>"true_value"=>"..."</b> - set value for 
checked checkbox<br /><b>"false_value"=>"..."</b> - set value for unchecked 
checkbox<br /></p>

<p>For the "enum" type:<br />
<b>"source"=>"..."</b> - source for enum type. Possible values: "self" or from customized array<br />
<b>"view_type"=>"..."</b> - view type of the field: dropdownlist (default) or radiobutton<br />
<b>"radiobuttons_alignment"=>"horizontal|vertical"</b> - type of radiobuttons alignment<br />
<b>"multiple"=>...</b> - true or false (default) - if allow multirows listbox<br />
<b>"multiple_size"=>...</b> - number of rows in multirows listbox (4 - default)<br />
</p>

<pre><font color=green><b>
// Fill enum type from the array (optional)</b></font><font color=darkblue><b>
$fill_from_array = array("0"=>"No", "1"=>"Yes", "2"=>"Don't know", "3"=>"My be"); </b></font> 
</pre>

<p>For the "textarea" type:<br /><b>"edit_type"=>"..."</b> - simple view - 
"simple" or advanced wysiwyg editor - "wysiwyg"<br /><b>"resizable"=>"..."</b> 
- if the textarea can be resized by mouse<br /><b>"rows"=>"..."</b> - number of 
rows (default 7)<br /><b>"cols"=>"..."</b> - number of columns (default - 
50)<br /><br /></p>

<p>For the "delimiter" type:<br /><b>"inner_html"=>"..."</b> - html for delimiter row<br /><br /></p>

<p>For the "validator" type:<br />
<b>"for_field"=>"..."</b> - name of the field for validation process<br />
<b>"validation_type"=>"password|email"</b> - type of validation field<br />
</p>

<pre><font color=darkblue><b>
$em_columns = array(
    "FieldName_1"  =>array("header"=>"Name_A", "type"=>"textbox",    "req_type"=>"rt", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>""),
    "FieldName_2"  =>array("header"=>"Name_B", "type"=>"textarea",   "req_type"=>"rt", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "edit_type"=>"simple|wysiwyg", "resizable"=>"false", "rows"=>"7", "cols"=>"50"),
    "FieldName_3"  =>array("header"=>"Name_C", "type"=>"label",      "req_type"=>"rt", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>""),
    "FieldName_4"  =>array("header"=>"Name_D", "type"=>"date",       "req_type"=>"rt", "width"=>"187px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "calendar_type"=>"popup|floating"),
    "FieldName_5"  =>array("header"=>"Name_E", "type"=>"datetime",   "req_type"=>"st", "width"=>"187px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "calendar_type"=>"popup|floating"),
    "FieldName_6"  =>array("header"=>"Name_F", "type"=>"time",       "req_type"=>"st", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>""),
    "FieldName_7"  =>array("header"=>"Name_G", "type"=>"image",      "req_type"=>"st", "width"=>"220px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "target_path"=>"uploads/", "max_file_size"=>"100000|100K|10M|1G", "image_width"=>"Xpx", "image_height"=>"Ypx", "magnify"=>"false", "file_name"=>"Image_Name", "host"=>"local|remote"),
    "FieldName_8"  =>array("header"=>"Name_H", "type"=>"password",   "req_type"=>"rp", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>""),
    "FieldName_9"  =>array("header"=>"Name_I", "type"=>"enum",       "req_type"=>"st", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "source"=>"self"|$fill_from_array, "view_type"=>"dropdownlist(default)|radiobutton", "radiobuttons_alignment"=>"horizontal|vertical", "multiple"=>false, "multiple_size"=>"4"),
    "FieldName_10" =>array("header"=>"Name_J", "type"=>"print",      "req_type"=>"st", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>""),
    "FieldName_11" =>array("header"=>"Name_K", "type"=>"checkbox",   "req_type"=>"st", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "true_value"=>1, "false_value"=>0),
    "FieldName_12" =>array("header"=>"Name_L", "type"=>"file",       "req_type"=>"st", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "target_path"=>"uploads/", "max_file_size"=>"100000|100K|10M|1G", "file_name"=>"File_Name", "host"=>"local|remote"),
    "FieldName_13" =>array("header"=>"Name_M", "type"=>"link",       "req_type"=>"st", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "field_key"=>"field_name_0"|"field_key_1"=>"field_name_1"|..., "field_data"=>"field_name_2", "target"=>"_new", "href"=>"http://mydomain.com?act={0}&act={1}&code=ABC"),
    "FieldName_14" =>array("header"=>"Name_N", "type"=>"foreign_key","req_type"=>"ri", "width"=>"210px", "title"=>"", "readonly"=>false, "default"=>"", "unique"=>false, "unique_condition"=>"", "visible"=>"true"),
    "FieldName_15" =>array("header"=>"",       "type"=>"hidden",     "req_type"=>"st", "default"=>"default_value", "visible"=>"true", "unique"=>false|true),
    "validator"    =>array("header"=>"Name_O", "type"=>"validator",  "req_type"=>"rv", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "visible"=>"true", "on_js_event"=>"", "for_field"=>"", "validation_type"=>"password|email"),
    "delimiter"    =>array("inner_html"=>"<br />"),
);<br />
$dgrid->SetColumnsInEditMode($em_columns);
</b></font>
</pre>
<p>If you want to get auto-genereted columns - set 
<b>$auto_column_in_edit_mode</b> as true. </p><pre><font color=green><b>
##  *** set auto-genereted columns in edit mode
</b></font><font color=darkblue><b>
$auto_column_in_edit_mode = false;
$dgrid->SetAutoColumnsInEditMode($auto_column_in_edit_mode);
</b></font>
</pre>
<p>then uncomment and set right values for the next rows: </p><pre><font color=green><b>
##  ***  set settings for add/edit/details modes
</b></font><font color=darkblue><b>
$table_name  = "table_name";
$primary_key = "primary_key";
$condition   = "";
$dgrid->SetTableEdit($table_name, $primary_key, $condition);
</b></font>
</pre>
<p>Settings for the foreign keys. </p>
<p><b>"ForeignKey_1/2/3.../n"=>"..."</b> - foreign key from "Edit" 
table<br /></p>
<p><b>"table"=>"..."</b> - foreign table name<br />
<b>"field_key"=>"..."</b> - key in foreign table<br />
<b>"field_name"=>"..."</b> - filed, that will be viewed  or virtual field: "field_name"=>"CONCAT(field1,','field2) as field3"<br />
<b>"view_type"=>"..."</b> - view type. Possible values: dropdownlist(default), radiobutton or texbox<br />
<b>"condition"=>"..."</b> - some condition. Ex.: TableName_1.FieldName > 'a' AND TableName_1.FieldName 
< 'c'<br /><b>"order_by_field"=>"..."</b> - sorting order by the 
filed<br /><b>"order_type"=>"..."</b> - sorting 
type<br /><b>"on_js_event"=>"..."</b> - javascript code or js function on some 
event. Example: onClick(alert('Clicked!'))<br /></p><pre><font color=green><b>
##  *** set foreign keys for add/edit/details modes (if there are linked tables)
##  *** Ex.: "condition"=>"TableName_1.FieldName > 'a' AND TableName_1.FieldName < 'c'"
##  *** Ex.: "on_js_event"=>"onclick='alert(\"Yes!!!\");'"
</b></font><font color=darkblue><b>
$foreign_keys = array(
    "ForeignKey_1"=>array("table"=>"TableName_1", "field_key"=>"FieldKey_1", "field_name"=>"FieldName_1", "view_type"=>"dropdownlist(default)|radiobutton|textbox", "condition"=>"", "order_by_field"=>"My_Field_Name", "order_type"=>"ASC|DESC", "on_js_event"=>""),
    "ForeignKey_2"=>array("table"=>"TableName_2", "field_key"=>"FieldKey_2", "field_name"=>"FieldName_2", "view_type"=>"dropdownlist(default)|radiobutton|textbox", "condition"=>"", "order_by_field"=>"My_Field_Name", "order_type"=>"ASC|DESC", "on_js_event"=>"")
);<br /> 
$dgrid->SetForeignKeysEdit($foreign_keys);
</b></font>
</pre>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a 
title="Edit section: Step 8. Bind the DataGrid." 
href="getting_started.htm?title=Getting_Started&amp;action=edit&amp;section=12">edit</a>]</div><a 
name=Step_8._Bind_the_DataGrid.></a>
<h3><b>Step 8. Bind the DataGrid.</b></h3>
<p>+---------------------------------------------------------------------------+<br />| 
8. Bind the DataGrid: 
|<br />+---------------------------------------------------------------------------+<br /></p>
<p>Now we need to bind our DataDrid and draw it on the screen. </p><pre><font color=green>*** bind the DataGrid and draw it on the screen</font>
<font color=darkblue><b>
$dgrid->Bind(true);
ob_end_flush();
</b></font>
</pre>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a 
title="Edit section: Not documented features and functions." 
href="getting_started.htm?title=Getting_Started&amp;action=edit&amp;section=13">edit</a>]</div><a 
name=Not_documented_features_and_functions.></a>
<h2><b>Not documented features and functions.</b></h2>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a 
title="Edit section: Properties" 
href="getting_started.htm?title=Getting_Started&amp;action=edit&amp;section=14">edit</a>]</div><a 
name=Properties></a>
<h3><b>Properties </b></h3>
<HR>

<p>Allows automatical getting focus on the first displayed field in edit mode (default - false) </p><pre><font color=darkblue><b>first_field_focus_allowed = true|false;</b></font></pre>
<p>Allows floating tool tips (default - false) </p><pre><font color=darkblue><b>floating_tool_tips_allowed = true|false;</b></font></pre>
<p>Attributes in view mode for labels and in add/edit/details modes for textboxes </p><pre><font color=darkblue><b>"pre_addition"=>""; and "post_addition"=>"";</b></font></pre>
<p>Hides DataGrid before searching and shows DataGrid after the search is completed (default - false) </p><pre><font color=darkblue><b>hide_grid_before_serach = true|false;</b></font></pre>
<p>Return Datagrid to specified mode after updating (default - view) </p><pre><font color=darkblue><b>mode_after_update = "edit";</b></font></pre>
<p>Runs user's pre-defined function on_item_created event
attributes in view/add/edit/details modes for customized work with field value.
This function must be defined with 1 parameter, that will get fild's data.
Ex.: function function_name($field_value){ ... return $new_field_value;}    
</p><pre><font color=darkblue><b>"on_item_created" => "function_name"</b></font></pre>
<p>Define a text, that will be shows on empty dataset
<pre><font color=darkblue><b>NoDataFoundText = "";</b></font></pre>
</p>
<p>"Autocomplete" attribute for textboxes in add/edit modes (default - "on")</p><pre><font color=darkblue><b>"autocomplete"=>"on|off";</b></font></pre>
<p>Attributes in view/add/edit/details modes for customized work with field value, <br>function_name must be defined with 1 parameter, that will get filed data. <br>Ex.: function_name($field_value){ ... }</p><pre><font color=darkblue><b>"on_item_created"=>"function_name"</b></font></pre>


<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a 
title="Edit section: Methods" 
href="getting_started.htm?title=Getting_Started&amp;action=edit&amp;section=15">edit</a>]</div><a 
name=Methods></a>
<h3><b>Methods</b></h3>
<HR>

<p>Executes SQL query - use it after dataSource() method only (after the using 
dataSource() need to be recalled) </p><pre><font color=darkblue><b>executeSql()</b></font>
<font color=green>
// Example:
// $sql = "SELECT * FROM tblPresidents WHERE tblPresidents.CountryID = ".$_GET['f_rid'];
// $dSet = $dgrid->ExecuteSql($sql);
// while($row = $dSet->fetchRow()){
//  for($c = 0; ($c < $dSet->numCols()); $c++){ echo $row[$c]." "; }
//  echo "<br>";
// }
</font>
</pre>
<p>Retuns first column data from SELECT SQL - use it after dataSource() method 
only (after the using dataSource() need to be recalled) </p><pre><font color=darkblue><b>selectSqlItem()</b></font>
<font color=green>
// Example:
// $sql = "SELECT COUNT(presidentID) FROM tblPresidents WHERE CountryID = ".$_GET['f_rid'];
// $presidents = $dgrid->SelectSqlItem($sql);
</font></pre>
<p>Allows rows highlighting (default - true) </p><pre><font color=darkblue><b>allowHighlighting(true|false)</b></font></pre>
<p>Display validation error all together or separately </p><pre><font color=darkblue><b>setJsErrorsDisplayStyle("all"|"each")</b></font></pre>
<p>Returns next id of edit table </p><pre><font color=darkblue><b>getNextId()</b></font></pre>
<p>Returns current id of edit table </p><pre><font color=darkblue><b>getCurrentId()</b></font></pre>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a 
title="Edit section: Features" 
href="getting_started.htm?title=Getting_Started&amp;action=edit&amp;section=16">edit</a>]</div><a 
name=Features></a>
<h3><b>Features</b></h3>
<HR>
<p>Allows using user's javascript function for extra checkings on form submition 
in edit mode </p><pre><font color=darkblue><b><script>onSubmitMyCheck()</script></b></font>
<font color=green>
// Example: 
// unique_prefix_ - an unique prefix for the datagrid
// &lt;script type='text/javascript'>
// function unique_prefix_onSubmitMyCheck(){
//   alert("Thanks for adding/updating your data!");
//   return true;
// }	
// &lt;/script>
</font>
</pre>

<p>Allows to reload form in Edit mode </p><pre><font color=darkblue><b>"on_js_event"
=>"onchange='formAction(\"\", \"\", \"".$dgrid->uniquePrefix."\", \"".$dgrid->HTTP_URL."\", \"".$_SERVER['QUERY_STRING']."\")'"</b></font></pre>

<p>
true - draw DataGrid on the screen<br>
false - do all nedded actions, but don't draw datagrid on the screen
</p><pre><font color=darkblue><b>bind(true|false)</b></font></pre>


<h3><b>Tricks</b></h3>
<HR>

<p>1. Set default value, that disappears on focus:</p>
<pre><font color=darkblue><b>
"default"=>"http://www.website.com",
"on_js_event"=>"onBlur='if(this.value == \"\")
this.value = \"http://www.website.com\";
this.style.color=\"#f68d6f\";' onClick='if(this.value==\"http://www.website.com\")
this.value=\"\"; this.style.color=\"#000000\";'",
</b></font></pre>

<p>2. Set uniquie value for uploading image:</p>
<pre><font color=darkblue><b>
a) "file_name"=>"img_".((isset($_GET['prfx_mode']) && ($_GET['prfx_mode'] == "add")) ? $dgrid->GetNextId() : $dgrid->GetCurrentId())
b) "file_name"=>"img_".((isset($_GET['prfx_mode']) && ($_GET['prfx_mode'] == "add")) ? $dgrid->GetRandomString("10") : $dgrid->GetCurrentId())
</b></font></pre>

<div class=printfooter>Retrieved from "<a 
href="getting_started.htm?title=Getting_Started">getting_started.htm?title=Getting_Started</a>"</div><!-- end content -->
<div class=visualClear></div></div></div></div>
<div id=column-one>
<div class=portlet id=p-cactions>
<H5>Views</H5>
<UL>
  <LI class=selected id=ca-nstab-main><a 
  href="getting_started.htm?title=Getting_Started">Article</a> 

  </UL></div>
<div class=portlet id=p-personal>
<H5>Personal tools</H5>
<div class=pBody>

</div></div>
<div class=portlet id=p-logo><a title="Main Page" 
style="BACKGROUND-IMAGE: url(/dgwiki/skins/common/images/wiki.png)" 
href="getting_started.htm?title=Main_Page"></a></div>
<SCRIPT type=text/javascript> if (window.isMSIE55) fixalpha(); </SCRIPT>

<div class=portlet id=p-navigation>
<H5>Navigation</H5>
<div class=pBody>
<UL>
  <LI id=n-mainpage><a 
  href="getting_started.htm?title=Main_Page">Main 
  Page</a> 
  <LI id=n-portal><a 
  href="getting_started.htm?title=DataGrid_Wiki:Community_Portal">Community 
  portal</a> 
  <LI id=n-currentevents><a 
  href="getting_started.htm?title=Current_events">Current 
  events</a> 
  <LI id=n-recentchanges><a 
  href="getting_started.htm?title=Special:Recentchanges">Recent 
  changes</a> 
  <LI id=n-randompage><a 
  href="getting_started.htm?title=Special:Random">Random 
  page</a> 
  <LI id=n-help><a 
  href="getting_started.htm?title=Help:Contents">Help</a> 

  <LI id=n-sitesupport><a 
  href="getting_started.htm?title=DataGrid_Wiki:Site_support">Donations</a> 
  </LI></UL></div></div>
<div class=portlet id=p-search>
<H5><LABEL for=searchInput>Search</LABEL></H5>
<div class=pBody id=searchBody>
<FORM id=searchform action="getting_started.htm?title=Special:Search">
<div><INPUT id=searchInput accessKey=f name=search> <INPUT class=searchButton id=searchGoButton type=submit value=Go name=go>&nbsp; <INPUT class=searchButton type=submit value=Search name=fulltext> 
</div></FORM></div></div>
<div class=portlet id=p-tb>
<H5>Toolbox</H5>
<div class=pBody>
<UL>
  <LI id=t-whatlinkshere><a 
  href="getting_started.htm?title=Special:Whatlinkshere/Getting_Started">What 
  links here</a> 
  <LI id=t-recentchangeslinked><a 
  href="getting_started.htm?title=Special:Recentchangeslinked/Getting_Started">Related 
  changes</a> 
  <LI id=t-specialpages><a 
  href="getting_started.htm?title=Special:Specialpages">Special 
  pages</a> 
  <LI id=t-print><a 
  href="getting_started.htm?title=Getting_Started&amp;printable=yes">Printable 
  version</a> 
  <LI id=t-permalink><a 
  href="getting_started.htm?title=Getting_Started&amp;oldid=1643">Permanent 
  link</a> </LI></UL></div></div></div><!-- end of the left (by default at least) column -->
<div class=visualClear></div>
<div id=footer>
<div id=f-poweredbyico><a href="http://www.mediawiki.org/"><IMG alt=MediaWiki 
src="inc/poweredby_mediawiki_88x31.png"></a></div>
<div id=f-copyrightico><a href="http://www.gnu.org/copyleft/fdl.html"><IMG 
alt="GNU Free Documentation License 1.2" 
src="inc/gnu-fdl.png"></a></div>
<UL id=f-list>
  <LI id=lastmod>This page was last modified 16:12, 17 August 2008. 
  <LI id=viewcount>This page has been accessed 13,677 times. 
  <LI id=copyright>Content is available under <a class="external " 
  title=http://www.gnu.org/copyleft/fdl.html 
  href="http://www.gnu.org/copyleft/fdl.html" rel=nofollow>GNU Free 
  Documentation License 1.2</a>. 
  <LI id=privacy><a title="DataGrid Wiki:Privacy policy" 
  href="getting_started.htm?title=DataGrid_Wiki:Privacy_policy">Privacy 
  policy</a> 
  <LI id=about><a title="DataGrid Wiki:About" 
  href="getting_started.htm?title=DataGrid_Wiki:About">About 
  DataGrid Wiki</a> 
  <LI id=disclaimer><a title="DataGrid Wiki:General disclaimer" 
  href="getting_started.htm?title=DataGrid_Wiki:General_disclaimer">Disclaimers</a> 
  </LI></UL></div>
<SCRIPT 
type=text/javascript> if (window.runOnloadHook) runOnloadHook();</SCRIPT>
</div>
</body></html>
Return current item: PHP DataGrid