} else { $where = ""; $limit = 10; } } } $tbl = new ajaxCRUD("點位", "point", "id"); //$tbl->omitPrimaryKey(); $tbl->disallowEdit("id"); //$tbl->turnOffAjaxAdd(); // $tbl->turnOffAjaxEditing(); if (!empty($where)) { $tbl->addWhereClause($where); } $tbl->setLimit($limit); $tbl->omitField("owner"); $tbl->displayAs("name", "名稱"); $tbl->displayAs("alias", "別名"); $tbl->displayAs("type", "種類"); $tbl->formatFieldWithFunction('type', 'showIcon'); $tbl->displayAs("class", "等"); $tbl->displayAs("number", "號碼"); $tbl->displayAs("status", "狀態"); $tbl->displayAs("ele", "高度"); $tbl->displayAs("comment", "註解"); $tbl->displayAs("mt100", "百岳"); $tbl->displayAs("checked", "檢查"); $tbl->defineCheckbox('checked', '1', '0'); //$tbl->defineCheckbox('mt100',1,0); if ($_GET['x'] && $_GET['y']) { $tbl->setInitialAddFieldValue('x', $_GET['x']);
require_once 'crud/preheader.php'; #the code for the class include 'crud/ajaxCRUD.class.php'; $tblDemo = new ajaxCRUD("Item", "tblDemo", "pkID", "../"); $tblDemo->omitPrimaryKey(); #the table fields have prefixes; i want to give the heading titles something more meaningful $tblDemo->displayAs("fldField1", "IP address"); $tblDemo->displayAs("fldField2", "IP mask"); $tblDemo->displayAs("fldCertainFields", "Device type"); $tblDemo->displayAs("fldLongField", "Device description"); $tblDemo->displayAs("fldCheckbox", "Password"); #set the textarea height of the longer field (for editing/adding) $tblDemo->setTextareaHeight('fldLongField', 150); #i could omit a field if I wanted #http://ajaxcrud.com/api/index.php?id=omitField $tblDemo->omitField("fldCheckbox"); $allowableValues = array("federateur1", "federateur2", "backup", "acces"); $tblDemo->defineAllowableValues("fldCertainFields", $allowableValues); //set field fldCheckbox to be a checkbox #set the number of rows to display (per page) $tblDemo->setLimit(30); #set a filter box at the top of the table //$tblDemo->addAjaxFilterBox('fldField1'); #if really desired, a filter box can be used for all fields //$tblDemo->addAjaxFilterBoxAllFields(); #i can set the size of the filter box //$tblDemo->setAjaxFilterBoxSize('fldField1', 3); #i can format the data in cells however I want with formatFieldWithFunction #this is arguably one of the most important (visual) functions $tblDemo->formatFieldWithFunction('fldField1', 'makeBlue'); $tblDemo->formatFieldWithFunction('fldField2', 'makeBold');