Live Examples
Example 12: Add Additional Controls to Edit Form
Call add_control() to add additional HTML controls in the edit form.
$dg = new C_DataGrid($hostName, $userName, $password, $dbName); $dg -> set_gridpath ("include/"); $dg -> set_sql ("SELECT * FROM Employees"); $dg -> set_sql_table ("Employees"); $dg -> set_sql_key ("EmployeeId"); // change column titles $dg -> set_col_title ("EmployeeId", "Employee ID"); $dg -> set_col_title ("LastName", "Last Name"); $dg -> set_col_title ("FirstName", "First Name"); // set background and mouse over color $dg -> set_alt_bgcolor ("#ffcc99, #ffccdd"); $dg -> set_onmouseover ("yellow"); // hide a column $dg -> set_col_hidden ("Notes"); // display URL as hyperlink $dg -> set_col_link ("ReportsTo", "/query.php?EmployeeId=", "EmployeeId", "target='_new'"); // set page size $dg -> set_page_size (20); // make the datagrid editable $dg -> set_allow_actions(true); // set data administrative level // "V" means View, "E" means Edit, and "D" means Delete. $dg -> set_action_type ("VE"); // view and edit only // make BirthDate and HomePhone read only $dg -> set_fields_readonly("LastName, HomePhone"); // sum up columns $dg -> set_col_sum_enabled(true); $dg -> set_col_sum ("Salary"); $dg -> set_col_sum ("Age"); // add Checkbox HTML control to status$dg -> add_control("Status",CHECKBOX,"parttime"=>"Part Time","contract"=>"Contract"),",");$dg -> display();




