#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(); #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'); //$tblDemo->modifyFieldWithClass("fldField1", "zip required"); //for testing masked input functionality //$tblDemo->modifyFieldWithClass("fldField2", "phone"); //for testing masked input functionality //$tblDemo->onAddExecuteCallBackFunction("mycallbackfunction"); //uncomment this to try out an ADD ROW callback function $tblDemo->deleteText = "delete"; ?>
#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 #set the number of rows to display (per page) $tblEventAttendee->setLimit(25); //after 25 people, the resultset will paginate $tblEventAttendee->setAddPlaceholderText("fldTimeArriving", $fldTime); $tblEventAttendee->setAddFieldNote("fldTimeArriving", "Leave blank if you'll be on time."); $tblEventAttendee->setAddFieldNote("fldWillBeLate", "If you will be arriving late, please enter the time in the next box."); $tblEventAttendee->modifyFieldWithClass("fldTimeArriving", "time"); $tblEventAttendee->modifyFieldWithClass("fldLastName", "required"); $tblEventAttendee->modifyFieldWithClass("fldFirstName", "required"); $tblEventAttendee->formatFieldWithFunction("fldWillBeLate", "displayWillBeLate"); $tblEventAttendee->formatFieldWithFunctionAdvanced("fldTimeArriving", "displayArrivalTime"); $tblEventAttendee->emptyTableMessage = "No one has signed up yet! Press the '<b>Add Person</b>' button below to sign up for this event."; $tblEventAttendee->addMessage = "You have been added to this event."; $tblEventAttendee->setCSSFile("cuscosky.css"); //i liked this table feel; but any css can be used from http://icant.co.uk/csstablegallery #implement a callback function on signing up to create cookie $tblEventAttendee->onAddExecuteCallBackFunction("onAddCallBackFunction");
$tblFriend->displayAs("fldPhone", "Phone"); $tblFriend->displayAs("fldEmail", "Email"); $tblFriend->displayAs("fldBestFriend", "Best Friend?"); $tblFriend->displayAs("fldDateMet", "Date We Met"); $tblFriend->displayAs("fldFriendRating", "Rating"); $tblFriend->displayAs("fldOwes", "Owes Me How Much?"); $tblFriend->displayAs("fldPicture", "Image"); $tblFriend->displayAs("fkMarriedTo", "Married To"); #disallow new friends to be added (removes the add button) //$tblFriend->disallowAdd(); #use if you only want to show a few of the fields (not all) //$tblFriend->showOnly("fldName, fldAddress, fldState, fldOwes"); #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");
} } 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']) {
$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); $tblDemo2->setTextareaHeight('fldLongField', 50); $tblDemo2->setLimit(20); $tblDemo2->addAjaxFilterBox('fldField1'); $tblDemo2->formatFieldWithFunction('fldField2', 'makeBlue'); $tblDemo2->formatFieldWithFunction('fldField1', 'makeBold'); echo "<h2>Table tblDemo2</h2>\n"; $tblDemo2->showTable(); function makeBold($val) { return "<b>{$val}</b>"; } function makeBlue($val) { return "<span style='color: blue;'>{$val}</span>"; }
#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(100); #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 //style$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'); //$tblDemo->modifyFieldWithClass("fldField1", "zip required"); //for testing masked input functionality //$tblDemo->modifyFieldWithClass("fldField2", "phone"); //for testing masked input functionality //$tblDemo->onAddExecuteCallBackFunction("mycallbackfunction"); //uncomment this to try out an ADD ROW callback function $tblDemo->deleteText = "delete"; ?>
$chatlines = new ajaxCRUD("chatlines", "chatlines", "id"); $chatlines->setLimit(10); $groups = new ajaxCRUD("groups", "groups", "id"); $groups->setLimit(10); $handles = new ajaxCRUD("handles", "handles", "id"); $handles->setLimit(10); $messages = new ajaxCRUD("messages", "messages", "id"); $messages->setLimit(10); $roles = new ajaxCRUD("roles", "roles", "id"); $roles->setLimit(10); $tickets = new ajaxCRUD("tickets", "tickets", "id"); $tickets->setLimit(10); $updates = new ajaxCRUD("updates", "updates", "id"); $updates->setLimit(10); $users = new ajaxCRUD("users", "users", "id"); $users->setLimit(10); ?> </head> <body> <div id="TopContainer" class="rounded"></div> <div id="MainContainer"> <span id="select-table"> <select id="table-selector"> <option value="#autotext-div">autotext</option> <option value="#chatlines-div">chatlines</option> <option value="#groups-div">groups</option> <option value="#handles-div">handles</option> <option value="#messages-div">messages</option> <option value="#roles-div">roles</option> <option value="#tickets-div">tickets</option>
//$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 Value 1", "Allowable Value2", "Dropdown Value", "CRUD"); $tblDemo->defineAllowableValues("fldCertainFields", $allowableValues); #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(3); #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'); #actually show the table $tblDemo->showTable(); #my self-defined functions used for formatFieldWithFunction function makeBold($val) {