After enabling edit, set types of data grid edit controls with set_col_edittype() for any editable column. List of available controls:
- text
- textarea
- select
- checkbox
- password
- autocomplete (version 6+) – New!
Text and Textarea are set automatically based on the database access library ADOdb metatype. For WYSIWYG control, use set_col_wysiwyg() method instead.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | $dg = new C_DataGrid("select * from employees", "employeeNumber", "Employees"); $dg -> set_col_title("employeeNumber", "Emp No."); $dg -> set_col_title("lastName", "Last Name"); $dg -> set_col_title("firstName", "First Name"); $dg -> set_col_title("isActive", "Active?"); $dg -> set_col_format("email", "email"); $dg -> enable_edit("FORM", "CRUD"); $dg -> set_row_color("","","#DDEEF5"); $dg -> set_col_hidden('employeeNumber',false); $dg -> set_col_edittype("isActive", "checkbox","1:0"); $dg -> set_col_edittype("reportsTo", "select", "Select employeeNumber, concat(firstName, ' ', lastName) from employees",false); $dg -> set_col_edittype("officeCode", "autocomplete", "Select officeCode,city from offices",false); // alternatively, for select type, you can hard-code the key value pair value // $dg -> set_col_edittype("officeCode", "select", "1:San Francisco;2:Boston;3:NYC;4:Paris;5:Tokyo;6:Sydney;7:London"); $dg -> display(); |