Sample 2-4. Advanced DataGrid code.

    1. All modes (Add/Edit/Details/Delete/View).
    2. All features.
    3. Two DataGrids on one page.
    4. Customized layout in Details mode.
Show Plain Text »
  1. <?php
  2.  
  3.  
  4. ## +---------------------------------------------------------------------------+
  5. ## | 1. Creating & Calling:                                                    |
  6. ## +---------------------------------------------------------------------------+
  7. ##  *** define a relative (virtual) path to datagrid.class.php file
  8. ##  *** directory (relatively to the current file)
  9. ##  *** RELATIVE PATH ONLY ***
  10. define ("DATAGRID_DIR", "datagrid/");                    
  11. require_once(DATAGRID_DIR."datagrid.class.php");
  12.  
  13. ##  *** creating variables that we need for database connection    
  14. $DB_USER = "db_user";
  15. $DB_PASS = "db_password";      
  16. $DB_HOST = "db_host";      
  17. $DB_NAME = "db_name";      
  18.  
  19. ##  *** put a primary key on the first place
  20. $sql=" SELECT "
  21.  ."demo_countries.id, "
  22.  ."demo_countries.region_id, "
  23.  ."demo_regions.name as region_name, "
  24.  ."demo_countries.name, "
  25.  ."demo_countries.description, "
  26.  ."demo_countries.picture_url, "
  27.  ."demo_countries.picture_url_1, "
  28.  ."demo_countries.independent_date, "
  29.  ."demo_countries.independent_time, "
  30.  ."FORMAT(demo_countries.population, 0) as population, "  
  31.  ."(SELECT COUNT(demo_presidents.id) FROM demo_presidents WHERE demo_presidents.country_id = demo_countries.id) as presidents, "
  32.  ." CASE WHEN demo_countries.is_democracy = 1 THEN 'Yes' ELSE 'No' END as is_democracy "
  33.  ."FROM demo_countries INNER JOIN demo_regions ON demo_countries.region_id=demo_regions.id ";
  34. ##  *** set needed options and create a new class instance
  35. $debug_mode = false;        /* display SQL statements while processing */    
  36. $messaging = true;          /* display system messages on a screen */
  37. $unique_prefix = "f_";    /* prevent overlays - must be started with a letter */
  38. $dgrid = new DataGrid($debug_mode, $messaging, $unique_prefix);
  39. ##  *** set data source with needed options
  40. $default_order = array("name"=>"ASC");
  41. $dgrid->DataSource("PDO", "mysql", $DB_HOST, $DB_NAME, $DB_USER, $DB_PASS, $sql, $default_order);            
  42. $dgrid->isDemo = true;
  43. $dgrid->controlsDisplayingType = "grouped";
  44.  
  45. ## +---------------------------------------------------------------------------+
  46. ## | 2. General Settings:                                                      |
  47. ## +---------------------------------------------------------------------------+
  48. $postback_method = "post";
  49. $dgrid->SetPostBackMethod($postback_method);
  50. ##  *** set encoding and collation (default: utf8/utf8_unicode_ci)
  51. $dg_encoding = "utf8";
  52. $dg_collation = "utf8_unicode_ci";
  53. $dgrid->SetEncoding($dg_encoding, $dg_collation);
  54. ##  *** set interface language (default - English)
  55. $dg_language = $lang;  
  56. $dgrid->SetInterfaceLang($dg_language);
  57. ##  *** set direction: "ltr" or "rtr" (default - "ltr")
  58. $direction = "ltr";
  59. $dgrid->SetDirection($direction);
  60. ##  *** set layouts: 0 - tabular(horizontal) - default, 1 - columnar(vertical)
  61. $layouts = array("view"=>"0", "edit"=>"1", "details"=>"2", "filter"=>"1");
  62. $dgrid->SetLayouts($layouts);
  63. ##  *** set templates
  64. $details_template = array("header"=>"", "body"=>"", "footer"=>"");
  65. $details_template["body"] = '
  66.  <table dir="ltr" class="x-blue_dg_table" align="center" width="60%">
  67.  <tr class="class_tr" bgcolor="#F7F9FB">
  68.      <td width="20%" class="class_td" align="center">{delimiter_1}{picture_url}</td>
  69.      <td width="20%" class="class_td" align="center">{delimiter_2}{picture_url_1}</td>
  70.      <td width="60%">
  71.          <table border=0>
  72.              <tr class="class_tr"><td class="x-blue_dg_td class_left" style="border:0px" nowrap><b>Region:</b> </td><td class="x-blue_dg_td class_left"  style="border:0px">{region_id}</td></tr>
  73.              <tr class="class_tr"><td class="x-blue_dg_td class_left" style="border:0px" nowrap><b>Country:</b> </td><td class="x-blue_dg_td class_left"  style="border:0px">{name}</td></tr>
  74.              <tr class="class_tr"><td class="x-blue_dg_td class_left" style="border:0px" nowrap><b>Independence Day:</b> </td><td class="x-blue_dg_td class_left"  style="border:0px">{independent_date}</td></tr>
  75.              <tr class="class_tr"><td class="x-blue_dg_td class_left" style="border:0px" nowrap><b>Democracy?</b> </td><td class="x-blue_dg_td class_left"  style="border:0px">{is_democracy}</td></tr>
  76.              <tr class="class_tr"><td class="x-blue_dg_td class_left" style="border:0px" nowrap><b>Population:</b> </td><td class="x-blue_dg_td class_left"  style="border:0px">{population}</td></tr>
  77.              <tr class="class_tr"><td class="x-blue_dg_td class_left" style="border:0px" nowrap><b>Description:</b> </td><td class="x-blue_dg_td class_left" style="border:0px">{description}</td></tr>
  78.          </table>
  79.      </td>
  80.  </tr>    
  81.  </table>
  82.  <br>
  83.  <table dir="ltr" class="class_table" align="center" width="60%">
  84.  <tr class="class_tr" bgcolor="#ffffff"  >    
  85.      <th width="100px" class="x-blue_dg_th class_right" align="right" wrap >[BACK]</th>
  86.  </tr>
  87.  </table>
  88.  <br><br><br>';
  89. $dgrid->SetTemplates("","",$details_template);
  90.  
  91. ##  *** set modes for operations ("type" => "link|button|image")
  92. ##  *** "byFieldValue"=>"fieldName" - make the field to be a link to edit mode page
  93. $modes = array(
  94.   "add"  =>array("view"=>true, "edit"=>false, "type"=>"link"),
  95.   "edit"         =>array("view"=>true, "edit"=>true,  "type"=>"image", "byFieldValue"=>""),
  96.   "details" =>array("view"=>true, "edit"=>false, "type"=>"image"),
  97.   "delete"  =>array("view"=>true, "edit"=>true,  "type"=>"image")
  98. );
  99. $dgrid->SetModes($modes);
  100. ##  *** allow mulirow operations
  101. $multirow_option = true;
  102. $dgrid->AllowMultirowOperations($multirow_option);
  103. $multirow_operations = array(
  104.   "delete"  => array("view"=>true),
  105.   "details" => array("view"=>true)
  106. );
  107. $dgrid->SetMultirowOperations($multirow_operations);  
  108. ##  *** set CSS class for datagrid
  109. ## "embedded" - use embedded classes, "file" - link external css file
  110. $dgrid->SetCssClass($css_class);
  111. ##  *** set other datagrid/s unique prefixes (if you use few datagrids on one page)
  112. ##  *** format (in wich mode to allow processing of another datagrids)
  113. ##  *** array("unique_prefix"=>array("view"=>true|false, "edit"=>true|false, "details"=>true|false));
  114. $anotherDatagrids = array("fp_"=>array("view"=>true, "edit"=>true, "details"=>false));
  115. $dgrid->SetAnotherDatagrids($anotherDatagrids);  
  116. ##  *** set DataGrid caption
  117. $dg_caption = '<b>My Favorite Lovely ApPHP DataGrid</b>';
  118. $dgrid->SetCaption($dg_caption);
  119.  
  120. ## +---------------------------------------------------------------------------+
  121. ## | 3. Printing & Exporting Settings:                                         |
  122. ## +---------------------------------------------------------------------------+
  123. ##  *** set printing option: true(default) or false
  124. $printing_option = false;
  125. $dgrid->AllowPrinting($printing_option);
  126.  
  127. ## +---------------------------------------------------------------------------+
  128. ## | 4. Sorting & Paging Settings:                                             |
  129. ## +---------------------------------------------------------------------------+
  130. ##  *** set sorting option: true(default) or false
  131. $sorting_option = true;
  132. $dgrid->AllowSorting($sorting_option);              
  133. ##  *** set paging option: true(default) or false
  134. $paging_option = true;
  135. $rows_numeration = false;
  136. $numeration_sign = "N #";      
  137. $dgrid->AllowPaging($paging_option, $rows_numeration, $numeration_sign);
  138. ##  *** set paging settings
  139. $bottom_paging = array("results"=>true, "results_align"=>"left", "pages"=>true, "pages_align"=>"center", "page_size"=>true, "page_size_align"=>"right");
  140. $top_paging = array();
  141. $pages_array = array("10"=>"10", "25"=>"25", "50"=>"50", "100"=>"100", "250"=>"250", "500"=>"500", "1000"=>"1000");
  142. $default_page_size = 10;
  143. $dgrid->SetPagingSettings($bottom_paging, $top_paging, $pages_array, $default_page_size);
  144.  
  145. ## +---------------------------------------------------------------------------+
  146. ## | 5. Filter Settings:                                                       |
  147. ## +---------------------------------------------------------------------------+
  148. ##  *** set filtering option: true or false(default)
  149. $filtering_option = true;
  150. $dgrid->AllowFiltering($filtering_option);
  151. ##  *** set aditional filtering settings
  152. $fill_from_array = array("10000"=>"10000", "250000"=>"250000", "5000000"=>"5000000", "25000000"=>"25000000", "100000000"=>"100000000");
  153. $filtering_fields = array(
  154.   "Region"      =>array("table"=>"demo_regions",   "field"=>"name", "source"=>"self", "order"=>"DESC", "operator"=>true, "type"=>"enum", "case_sensitive"=>false,  "comparison_type"=>"binary"),
  155.   "Country"     =>array("table"=>"demo_countries", "field"=>"name", "source"=>"self", "operator"=>true, "default_operator"=>"like", "type"=>"textbox", "case_sensitive"=>true,  "comparison_type"=>"string"),
  156.   "Date"        =>array("table"=>"demo_countries", "field"=>"independent_date", "source"=>"self", "operator"=>true, "type"=>"textbox", "case_sensitive"=>false,  "comparison_type"=>"string"),      
  157.   "Population"  =>array("table"=>"demo_countries", "field"=>"population", "source"=>$fill_from_array, "order"=>"DESC", "operator"=>true, "type"=>"dropdownlist", "case_sensitive"=>false, "comparison_type"=>"numeric")
  158. );
  159. $dgrid->SetFieldsFiltering($filtering_fields);
  160.  
  161. ## +---------------------------------------------------------------------------+
  162. ## | 6. View Mode Settings:                                                    |
  163. ## +---------------------------------------------------------------------------+
  164. ##  *** set columns in view mode
  165. $vm_columns = array(
  166.   "region_name"  =>array("header"=>"Region Name", "type"=>"label", "width"=>"130px", "align"=>"left",   "wrap"=>"nowrap", "text_length"=>"-1", "case"=>"normal"),
  167.   "name"         =>array("header"=>"Country Name", "type"=>"linktoedit", "align"=>"left", "width"=>"130px", "wrap"=>"nowrap", "text_length"=>"-1", "case"=>"normal", "sort_by"=>"name"),
  168.   "population"   =>array("header"=>"Population", "type"=>"label", "summarize"=>true, "align"=>"right",  "wrap"=>"nowrap", "text_length"=>"-1", "case"=>"normal"),
  169.   "presidents"   =>array("header"=>"Presidents", "type"=>"label", "summarize"=>true, "align"=>"right",  "wrap"=>"nowrap", "text_length"=>"-1", "case"=>"normal"),
  170.   "description"  =>array("header"=>"Short Description","type"=>"label", "align"=>"left",   "wrap"=>"wrap",   "text_length"=>"15", "case"=>"lower"),
  171.   "picture_url"  =>array("header"=>"Picture #1", "type"=>"image", "align"=>"center", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "case"=>"normal", "summarize"=>false, "on_js_event"=>"", "target_path"=>"uploads/", "default"=>"", "image_width"=>"17px", "image_height"=>"17px"),
  172.   "picture_url_1"=>array("header"=>"Picture #2", "type"=>"image", "align"=>"center", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "case"=>"normal", "summarize"=>false, "on_js_event"=>"", "target_path"=>"uploads/", "default"=>"", "image_width"=>"17px", "image_height"=>"17px"),
  173. );
  174. $dgrid->SetColumnsInViewMode($vm_columns);
  175.  
  176. ## +---------------------------------------------------------------------------+
  177. ## | 7. Add/Edit/Details Mode Settings:                                        |
  178. ## +---------------------------------------------------------------------------+
  179. ##  ***  set settings for add/edit/details modes
  180. $table_name  = "demo_countries";
  181. $primary_key = "id";
  182. $condition   = "";
  183. $dgrid->SetTableEdit($table_name, $primary_key, $condition);
  184. ##  *** set columns in edit mode
  185. $fill_from_array = array("10000"=>"10000", "250000"=>"250000", "5000000"=>"5000000", "25000000"=>"25000000", "100000000"=>"100000000");
  186. $em_columns = array(
  187.   "delimiter_1"    =>array("inner_html"=>"<b>First Image</b><br />"),
  188.   "delimiter_2"    =>array("inner_html"=>"<b>Second Image</b><br />"),
  189.   "region_id"        =>array("header"=>"Region",           "type"=>"textbox",  "width"=>"210px", "req_type"=>"rt", "title"=>"Region Name"),
  190.   "name"             =>array("header"=>"Country",          "type"=>"textbox",  "width"=>"210px", "req_type"=>"ry", "title"=>"Country Name", "unique"=>true),
  191.   "description"      =>array("header"=>"Short Descr.",     "type"=>"textarea", "width"=>"210px", "req_type"=>"rt", "title"=>"Short Description", "edit_type"=>"wysiwyg", "rows"=>"7", "cols"=>"50"),
  192.   "population"       =>array("header"=>"Peoples",          "type"=>"enum",     "source"=>$fill_from_array, "view_type"=>"dropdownlist",  "width"=>"139px", "req_type"=>"ri", "title"=>"Population (Peoples)"),
  193.   "picture_url"      =>array("header"=>"Image URL #1",        "type"=>"image",    "req_type"=>"st", "width"=>"210px", "title"=>"Picture", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "unique"=>false, "unique_condition"=>"", "on_js_event"=>"", "target_path"=>"uploads/", "max_file_size"=>"100K", "image_width"=>"100px", "image_height"=>"100px", "file_name"=>"", "host"=>"local"),
  194.   "picture_url_1"    =>array("header"=>"Image URL #2",        "type"=>"image",    "req_type"=>"st", "width"=>"210px", "title"=>"Picture", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "unique"=>false, "unique_condition"=>"", "on_js_event"=>"", "target_path"=>"uploads/", "max_file_size"=>"100K", "image_width"=>"100px", "image_height"=>"100px", "file_name"=>"", "host"=>"local"),
  195.   "is_democracy"     =>array("header"=>"Is Democracy",     "type"=>"checkbox", "true_value"=>1, "false_value"=>0,  "width"=>"210px", "req_type"=>"sy", "title"=>"Is Democraty"),
  196.   "independent_date" =>array("header"=>"Independence Day", "type"=>"date",     "width"=>"210px", "req_type"=>"rt", "title"=>"Independence Day"),
  197.   "independent_time" =>array("header"=>"Independence Time", "type"=>"time",     "width"=>"210px", "req_type"=>"rt", "title"=>"Independence Time")
  198. );
  199. $dgrid->SetColumnsInEditMode($em_columns);
  200. ##  *** foreign keys
  201. $foreign_keys = array(
  202.   "region_id"=>array("table"=>"demo_regions", "field_key"=>"id", "field_name"=>"name", "view_type"=>"dropdownlist", "order_by_field"=>"name", "order_type"=>"ASC")
  203. );
  204. $dgrid->SetForeignKeysEdit($foreign_keys);
  205.  
  206. ## +---------------------------------------------------------------------------+
  207. ## | 8. Bind the DataGrid:                                                     |
  208. ## +---------------------------------------------------------------------------+
  209. ##  *** bind the DataGrid and draw it on the screen
  210. $dgrid->Bind();        
  211.  
  212. // if we in EDIT mode of the first datagrid
  213. if(isset($_REQUEST['f_mode']) && ($_REQUEST['f_mode'] == "edit")){
  214.    
  215.    ## +---------------------------------------------------------------------------+
  216.    ## | 1. Creating & Calling:                                                    |
  217.    ## +---------------------------------------------------------------------------+
  218.    ##  *** put a primary key on the first place
  219.      $sql=" SELECT "
  220.        ."demo_presidents.id, "
  221.        ."demo_presidents.country_id, "
  222.        ."demo_presidents.name, "
  223.        ."demo_presidents.birth_date, "
  224.        ."demo_presidents.status "
  225.        ."FROM demo_presidents INNER JOIN demo_countries ON demo_presidents.country_id=demo_countries.id "
  226.        ."WHERE demo_presidents.country_id = ".$dgrid->GetCurrentId()." ";
  227.    ##  *** set needed options and create a new class instance
  228.      $debug_mode = false;        /* display SQL statements while processing */    
  229.      $messaging = true;          /* display system messages on a screen */
  230.      $unique_prefix = "fp_";    /* prevent overlays - must be started with a letter */
  231.      $dgrid1 = new DataGrid($debug_mode, $messaging, $unique_prefix);
  232.    ##  *** set data source with needed options
  233.      $default_order = array("id"=>"DESC");
  234.      $dgrid1->DataSource("PDO", "mysql", $DB_HOST, $DB_NAME, $DB_USER, $DB_PASS, $sql, $default_order);
  235.      $dgrid1->isDemo = true;
  236.  
  237.    ## +---------------------------------------------------------------------------+
  238.    ## | 2. General Settings:                                                      |
  239.    ## +---------------------------------------------------------------------------+
  240.    ##  *** set layouts: 0 - tabular(horizontal) - default, 1 - columnar(vertical)
  241.     $layouts = array("view"=>0, "edit"=>0, "filter"=>1);
  242.     $dgrid1->SetLayouts($layouts);
  243.    ##  *** set modes for operations ("type" => "link|button|image")
  244.    ##  *** "byFieldValue"=>"fieldName" - make the field to be a link to edit mode page
  245.     if($_REQUEST['f_mode'] == "edit"){    
  246.         $modes = array(
  247.             "add"=>array("view"=>true, "edit"=>false, "type"=>"link"),
  248.             "edit"=>array("view"=>true, "edit"=>true, "type"=>"link", "byFieldValue"=>""),
  249.             "details"=>array("view"=>false, "edit"=>false, "type"=>"link"),
  250.             "delete"=>array("view"=>true, "edit"=>false, "type"=>"image")
  251.         );
  252.       }else{
  253.         $modes = array(
  254.             "add"=>array("view"=>false, "edit"=>false, "type"=>"link"),
  255.             "edit"=>array("view"=>false, "edit"=>false, "type"=>"link", "byFieldValue"=>""),
  256.             "details"=>array("view"=>false, "edit"=>false, "type"=>"link"),
  257.             "delete"=>array("view"=>false, "edit"=>false, "type"=>"image")
  258.         );
  259.       }
  260.      $dgrid1->SetModes($modes);
  261.      $dgrid1->SetMultirowOperations($multirow_operations);  
  262.    ##  *** set CSS class for datagrid
  263.    ##  *** "default" or "blue" or "gray" or "green" or your css file relative path with name
  264.     $dgrid1->SetCssClass($css_class);
  265.    ##  *** set other datagrid/s unique prefixes (if you use few datagrids on one page)
  266.     $anotherDatagrids = array("f_"=>array("view"=>true, "edit"=>true, "details"=>true));
  267.      $dgrid1->SetAnotherDatagrids($anotherDatagrids);  
  268.    ##  *** set DataGrid caption
  269.     $dg_caption = "Presidents";
  270.      $dgrid1->SetCaption($dg_caption);
  271.  
  272.    ## +---------------------------------------------------------------------------+
  273.    ## | 3. Printing & Exporting Settings:                                         |
  274.    ## +---------------------------------------------------------------------------+
  275.    ##  *** set printing option: true(default) or false
  276.     $printing_option = false;
  277.      $dgrid1->AllowPrinting($printing_option);
  278.  
  279.    ## +---------------------------------------------------------------------------+
  280.    ## | 4. Sorting & Paging Settings:                                             |
  281.    ## +---------------------------------------------------------------------------+
  282.    ##  *** set sorting option: true(default) or false
  283.     $sorting_option = true;
  284.      $dgrid1->AllowSorting($sorting_option);              
  285.    ##  *** set paging option: true(default) or false
  286.     $paging_option = true;
  287.      $rows_numeration = false;
  288.      $numeration_sign = "N #";      
  289.      $dgrid1->AllowPaging($paging_option, $rows_numeration, $numeration_sign);
  290.    ##  *** set paging settings
  291.     $bottom_paging = array("results"=>true, "results_align"=>"left", "pages"=>true, "pages_align"=>"center", "page_size"=>true, "page_size_align"=>"right");
  292.      $top_paging = array();
  293.      $pages_array = array("10"=>"10", "25"=>"25", "50"=>"50", "100"=>"100", "250"=>"250", "500"=>"500", "1000"=>"1000");
  294.      $default_page_size = 10;
  295.      $dgrid1->SetPagingSettings($bottom_paging, $top_paging, $pages_array, $default_page_size);
  296.  
  297.    ## +---------------------------------------------------------------------------+
  298.    ## | 5. Filter Settings:                                                       |
  299.    ## +---------------------------------------------------------------------------+
  300.    ##  *** set filtering option: true or false(default)
  301.     $filtering_option = true;
  302.      $dgrid1->AllowFiltering($filtering_option);
  303.    ##  *** set aditional filtering settings
  304.     $filtering_fields = array(
  305.          "Name"=>array("table"=>"demo_presidents", "field"=>"name", "source"=>"self", "operator"=>true, "default_operator"=>"=", "order"=>"ASC", "type"=>"textbox", "case_sensitive"=>false, "comparison_type"=>"string")
  306.      );
  307.      $dgrid1->SetFieldsFiltering($filtering_fields);
  308.  
  309.    ## +---------------------------------------------------------------------------+
  310.    ## | 6. View Mode Settings:                                                    |
  311.    ## +---------------------------------------------------------------------------+
  312.    ##  *** set view mode table properties
  313.     $vm_table_properties = array("width"=>"70%");
  314.      $dgrid1->SetViewModeTableProperties($vm_table_properties);  
  315.    ##  *** set columns in view mode
  316.     $vm_columns = array(
  317.         "name"       =>array("header"=>"Name", "type"=>"label", "align"=>"left", "wrap"=>"wrap", "text_length"=>"20", "case"=>"normal"),
  318.         "birth_date" =>array("header"=>"Birth Date", "type"=>"label", "align"=>"center", "wrap"=>"nowrap", "text_length"=>"-1", "case"=>"normal"),
  319.         "status"     =>array("header"=>"Status", "type"=>"label", "align"=>"center", "wrap"=>"nowrap", "text_length"=>"30", "case"=>"normal")
  320.      );
  321.      $dgrid1->SetColumnsInViewMode($vm_columns);
  322.  
  323.    ## +---------------------------------------------------------------------------+
  324.    ## | 7. Add/Edit/Details Mode Settings:                                        |
  325.    ## +---------------------------------------------------------------------------+
  326.    ##  *** set add/edit mode table properties
  327.     $em_table_properties = array("width"=>"70%");
  328.      $dgrid1->SetEditModeTableProperties($em_table_properties);
  329.    ##  *** set details mode table properties
  330.     $dm_table_properties = array("width"=>"70%");
  331.      $dgrid1->SetDetailsModeTableProperties($dm_table_properties);
  332.    ##  ***  set settings for add/edit/details modes
  333.      $table_name  = "demo_presidents";
  334.       $primary_key = "id";
  335.       $condition   = "demo_presidents.country_id = ".$dgrid->rid." ";
  336.       $dgrid1->SetTableEdit($table_name, $primary_key, $condition);
  337.    ##  *** set columns in edit mode
  338.     $em_columns = array(
  339.         "country_id" =>array("header"=>"Country", "type"=>"textbox", "width"=>"160px", "req_type"=>"ri", "readonly"=>true),      
  340.         "name" =>array("header"=>"Name", "type"=>"textbox", "width"=>"140px", "req_type"=>"rt"),
  341.         "birth_date" =>array("header"=>"Birth Date", "type"=>"date", "width"=>"80px", "req_type"=>"rt"),
  342.         "status"=>array("header"=>"Status", "type"=>"enum", "req_type"=>"st", "width"=>"210px", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "unique"=>false, "unique_condition"=>"", "on_js_event"=>"", "source"=>"self", "view_type"=>"dropdownlist")
  343.      );
  344.      $dgrid1->SetColumnsInEditMode($em_columns);
  345.    ##  *** set foreign keys for add/edit/details modes (if there are linked tables)
  346.     $foreign_keys = array(
  347.         "country_id"=>array("table"=>"demo_countries ", "field_key"=>"id", "field_name"=>"name", "view_type"=>"dropdownbox", "condition"=>"")
  348.      );
  349.      $dgrid1->SetForeignKeysEdit($foreign_keys);
  350.  
  351.    ## +---------------------------------------------------------------------------+
  352.    ## | 8. Bind the DataGrid:                                                     |
  353.    ## +---------------------------------------------------------------------------+
  354.    ##  *** bind the DataGrid and draw it on the screen
  355.     $dgrid1->Bind();        
  356. }
  357.  
  358. ?>