<?php require_once "../conf.php"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Editable Datagrid - Inline Edit Action Column</title> </head> <body> <?php $dg = new C_DataGrid("SELECT * FROM orders", "orderNumber", "orders"); // change column titles $dg->set_col_title("orderNumber", "Order No."); $dg->set_col_title("orderDate", "Order Date"); $dg->set_col_title("shippedDate", "Shipped Date"); $dg->set_col_title("customerNumber", "Customer No."); $dg->set_col_hidden('comments'); // enable edit $dg->enable_edit("INLINE", "CRUD"); $dg->add_column("actions", array('name' => 'actions', 'index' => 'actions', 'width' => '70', 'formatter' => 'actions', 'formatoptions' => array('keys' => true)), 'Actions'); $dg->display(); ?> </body> </html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>phpGrid Virtual Column (Calculated Column)</title> </head> <body> <?php $dg = new C_DataGrid("SELECT * FROM orders", "orderNumber", "orders"); $dg->enable_edit('INLINE'); // creating a virtual column $col_formatter = <<<COLFORMATTER function(cellvalue, options, rowObject){ \tvar n1 = parseInt(rowObject[0],10), \t\tn2 = parseInt(rowObject[6],10); \treturn n1+n2; } COLFORMATTER; $dg->add_column('total', array('name' => 'total', 'index' => 'total', 'width' => '360', 'align' => 'right', 'formatter' => $col_formatter), 'Total (Virtual)'); $dg->display(); ?> Virtual Column <ul> <li>The col_name cannot contain space and must begin with a letter <li>Use "formatter" column property to hook up javascript function <li>The virtual column always adds to the end of the grid in the order of virtual column is created. <li>Text must be surrounded with single quote <li>Virtual column is not sortable. </ul>