示例#1
0
#i could disallow editing for certain, individual fields
//$tblDemo->disallowEdit('fldField2');
#i could set a field to accept file uploads (the filename is stored) if wanted
//$tblDemo->setFileUpload("fldField2", "uploads/");
#i can have a field automatically populate with a certain value (eg the current timestamp)
//$tblDemo->addValueOnInsert("fldField1", "NOW()");
#i can use a where field to better-filter my table
//$tblDemo->addWhereClause("WHERE (fldField1 = 'test')");
#i can order my table by whatever i want
//$tblDemo->addOrderBy("ORDER BY fldField1 ASC");
#i can set certain fields to only allow certain values
#http://ajaxcrud.com/api/index.php?id=defineAllowableValues
$allowableValues = array("Allowable Value1", "Allowable Value2", "Dropdown Value", "CRUD");
$tblDemo->defineAllowableValues("fldCertainFields", $allowableValues);
//set field fldCheckbox to be a checkbox
$tblDemo->defineCheckbox("fldCheckbox");
#i can disallow deleting of rows from the table
#http://ajaxcrud.com/api/index.php?id=disallowDelete
//$tblDemo->disallowDelete();
#i can disallow adding rows to the table
#http://ajaxcrud.com/api/index.php?id=disallowAdd
//$tblDemo->disallowAdd();
#i can add a button that performs some action deleting of rows for the entire table
#http://ajaxcrud.com/api/index.php?id=addButtonToRow
//$tblDemo->addButtonToRow("Add", "add_item.php", "all");
#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();
示例#2
0
#use if you want to rearrange the order your fields display (different from table schema)
//$tblFriend->orderFields("pkFriendID, fldAddress, fldName, fldState");
#set the number of rows to display (per page)
$tblFriend->setLimit(2);
#set a filter box at the top of the table
$tblFriend->addAjaxFilterBox('fldName', 20);
$tblFriend->addAjaxFilterBox('fldDateMet');
$tblFriend->addAjaxFilterBox('fkMarriedTo');
#allow picture to be a file upload
$tblFriend->setFileUpload('fldPicture', 'uploads/', 'uploads/');
//$tblFriend->disallowEdit("fldPicture");
$tblFriend->onAddExecuteCallBackFunction("myFunctionAfterAdd");
#format field output
$tblFriend->formatFieldWithFunction('fldOwes', 'addDollarSign');
$tblFriend->formatFieldWithFunction('fldPicture', 'displayImage');
$tblFriend->defineCheckbox("fldBestFriend", "Y", "N");
#modify field with class
$tblFriend->modifyFieldWithClass("fldDateMet", "datepicker");
$tblFriend->modifyFieldWithClass("fldZip", "zip required");
$tblFriend->modifyFieldWithClass("fldPhone", "phone required");
$tblFriend->modifyFieldWithClass("fldEmail", "email");
#set allowable values for certain fields
$ratingVals = array("0", "1", "2", "3", "4", "5");
$tblFriend->defineAllowableValues("fldFriendRating", $ratingVals);
$states = array(array("AL", "Alabama"), array("AK", "Alaska"), array("AZ", "Arizona"), array("AR", "Arkansas"), array("CA", "California"), array("CO", "Colorado"), array("CT", "Connecticut"), array("DE", "Delaware"), array("DC", "District Of Columbia"), array("FL", "Florida"), array("GA", "Georgia"), array("HI", "Hawaii"), array("ID", "Idaho"), array("IL", "Illinois"), array("IN", "Indiana"), array("IA", "Iowa"), array("KS", "Kansas"), array("KY", "Kentucky"), array("LA", "Louisiana"), array("ME", "Maine"), array("MD", "Maryland"), array("MA", "Massachusetts"), array("MI", "Michigan"), array("MN", "Minnesota"), array("MS", "Mississippi"), array("MO", "Missouri"), array("MT", "Montana"), array("NE", "Nebraska"), array("NV", "Nevada"), array("NH", "New Hampshire"), array("NJ", "New Jersey"), array("NM", "New Mexico"), array("NY", "New York"), array("NC", "North Carolina"), array("ND", "North Dakota"), array("OH", "Ohio"), array("OK", "Oklahoma"), array("OR", "Oregon"), array("PA", "Pennsylvania"), array("RI", "Rhode Island"), array("SC", "South Carolina"), array("SD", "South Dakota"), array("TN", "Tennessee"), array("TX", "Texas"), array("UT", "Utah"), array("VT", "Vermont"), array("VA", "Virginia"), array("WA", "Washington"), array("WV", "West Virginia"), array("WI", "Wisconsin"), array("WY", "Wyoming"));
$tblFriend->defineAllowableValues("fldState", $states);
#show CSV export button
$tblFriend->showCSVExportOption();
#use if you want to move the add form to the top of the page
//$tblFriend->displayAddFormTop();
#order the table by any field you want
示例#3
0
    $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']);
    $tbl->setInitialAddFieldValue('y', $_GET['y']);
    $tbl->displayAddFormTop();
}
if ($_GET['name']) {
    $tbl->setInitialAddFieldValue('name', $_GET['name']);
}
$tbl->showTable();
function showIcon($val)
{
    return sprintf("%s<img src='http://map.happyman.idv.tw/icon/%s.png'>", $val, urlencode($val));
}
?>
示例#4
0
#Create custom display fields
//$tblEventAttendee->displayAs("pkAttendeeID","User ID");
$tblEventAttendee->displayAs("fldFirstName", "First Name");
$tblEventAttendee->displayAs("fldLastName", "Last Name");
$tblEventAttendee->displayAs("fldPhone", "Phone #");
$tblEventAttendee->displayAs("fldWillBeLate", "Will You Be Late?");
$tblEventAttendee->displayAs("fldTimeArriving", "Arrival Time");
$tblEventAttendee->displayAs("fldComments", "Comments/Other");
$tblEventAttendee->displayAs("fldIPAddress", "IPAddress");
$tblEventAttendee->omitFieldCompletely("fldIPAddress");
$tblEventAttendee->omitFieldCompletely("fkEventID");
$tblEventAttendee->omitFieldCompletely("fldPhone");
$tblEventAttendee->omitFieldCompletely("fldAttending");
$tblEventAttendee->validateDeleteWithFunction("canRowBeModifiedOrDeleted");
$tblEventAttendee->validateUpdateWithFunction("canRowBeModifiedOrDeleted");
$tblEventAttendee->defineCheckbox("fldWillBeLate");
$tblEventAttendee->addOrderBy("ORDER BY fldFirstName ASC");
#Add WHERE clause so we only display information specific to the event that was selected
$tblEventAttendee->addWhereClause("WHERE fkEventID = {$eventID}");
#I could add filter boxes to the top, but have chosen not to do so; commenting these out
//$tblEventAttendee->addAjaxFilterBox("fldFirstName");
//$tblEventAttendee->addAjaxFilterBox("fldLastName");
//$tblEventAttendee->addAjaxFilterBox("fldAttending");
//using addValueOnInsert so when someone signs up it will automatically add them to this event
$tblEventAttendee->addValueOnInsert("fkEventID", $eventID);
//using addValueOnInsert to track their IP address
$tblEventAttendee->addValueOnInsert("fldIPAddress", $_SERVER["REMOTE_ADDR"]);
$tblEventAttendee->setTextboxWidth("fldTimeArriving", 8);
$tblEventAttendee->setTextboxWidth("fldLastName", 25);
$tblEventAttendee->setTextareaHeight("fldComments", 70);
//comment field should be a bit wider height
示例#5
0
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	</head>
<?php 
$tblDemo = new ajaxCRUD("Item", "tblDemo", "pkID", "../");
$tblDemo->omitPrimaryKey();
$tblDemo->displayAs("fldField1", "Field1");
$tblDemo->displayAs("fldField2", "Field2");
$tblDemo->displayAs("fldCertainFields", "Pick List");
$tblDemo->displayAs("fldLongField", "Long Field");
$tblDemo->displayAs("fldCheckbox", "Is Selected?");
$tblDemo->setTextareaHeight('fldLongField', 100);
$allowableValues = array("Allowable Value1", "Allowable Value2", "Dropdown Value", "CRUD");
$tblDemo->defineAllowableValues("fldCertainFields", $allowableValues);
//set field fldCheckbox to be a checkbox
$tblDemo->defineCheckbox("fldCheckbox", "1", "0");
$tblDemo->setLimit(5);
$tblDemo->addAjaxFilterBox('fldField1');
$tblDemo->formatFieldWithFunction('fldField1', 'makeBlue');
$tblDemo->formatFieldWithFunction('fldField2', 'makeBold');
echo "<h2>Table tblDemo</h2>\n";
$tblDemo->showTable();
echo "<br /><hr ><br />\n";
$tblDemo2 = new ajaxCRUD("Item", "tblDemo2", "pkID");
$tblDemo2->omitPrimaryKey();
$tblDemo2->displayAs("fldField1", "Field1");
$tblDemo2->displayAs("fldField2", "Field2");
$tblDemo2->displayAs("fldCertainFields", "Color");
$tblDemo2->displayAs("fldLongField", "Long Field");
$allowableValues2 = array("Green", "Blue", "Red", "Periwinkle");
$tblDemo2->defineAllowableValues("fldCertainFields", $allowableValues2);