PHP Classes

Eyesis Data Grid Control: Display data from a database in a sortable table

Recommend this page to a friend!
  Info   Screenshots Screenshots   View files View files (28)   DownloadInstall with Composer Download .zip   Reputation   Support forum (43)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 70%Total: 6,223 All time: 356 This week: 455Down
Version License PHP version Categories
eyedatagrid 1.0BSD License5HTML, PHP 5, Databases


This class can be used to display data from an SQL database in a sortable HTML table.

It can execute a given SQL query and generate HTML and Javascript to display the data in an HTML table.

The table listing can be sorted by clicking on the column header titles.

Data grid tables can also be displayed using Ajax.

Picture of Mike Frank
Name: Mike Frank <contact>
Classes: 3 packages by
Country: Canada Canada
Age: 35
All time rank: 26412 in Canada Canada
Week rank: 246 Up8 in Canada Canada Up


======================= EyeDataGrid Class Version: 1.0 Date: 05/11/2008 10:17:44 AM Author: Mike Frank <> Homepage: ======================= About ----- Their are plenty of PHP data grid controls out there, but none that could satisfy me. I use data grids on every web site I develop. They're great for displaying all kinds of data. I developed this datagrid to suit all my needs and more. Features -------- # Filtering and searching capabilities # Ability to change column headers # Capable of displaying images # Automatic row paging # Row selection # Supports MySQL database # Hide columns # Sort columns # Customizable look and feel through CSS # Can handle large data sets # Ability to add controls # Checkbox support # Specify column format types (such as percent, dollars, etc) # Much more... Files ----- -The main datagrid class -My mysql wrapper class used in most of my projects ex*.php -Example datagrid ex*.png -Image of the example sample data.sql -Sample data for playing around with (from examples) table.css -The style layout for the datagrid table Placeholder Variables --------------------- What is a placeholder in the datagrid control? A placeholder is a just the same as a variable. It is a name and references a column in a particular row. For exampe; lets say you had a Pets table with PetName, PetAge and PetComment columns. You can reference other columns in the PetComment by placing percent symbols (%) around the column name you are specifying. If the primary key is set during the setQuery method, you can use %_P% as a placeholder for the table's primary key. Where can I use this? This can be on the database or scripted. This can be used in column types criteria and criteria_2 param. Look below on TYPE_IMAGE and TYPE_CUSTOM for more examples. Column Types and Usage ---------------------- A quick overview of the available column types. I learn best by examples so I've included plenty for you. TYPE_ONCLICK -Sets a "onclick" call on a cell value -e.g: $db->setColumnType('FirstName', EyeDataGrid::TYPE_ONCLICK, "alert('Hello?')"); TYPE_HREF -Sets a href link on a cell value -e.g: $db->setColumnType('FirstName', EyeDataGrid::TYPE_HREF, ""); TYPE_DATE -Format a date -e.g: $db->setColumnType('Birthday', EyeDataGrid::TYPE_DATE, "M d, Y", true); // Converts to a timestamp and then to the formatted date -e.g: $db->setColumnType('Birthday', EyeDataGrid::TYPE_DATE, "M d, Y"); // Converts formatted date from a timestamp TYPE_IMAGE -Changes a column's values to a image -e.g: $db->setColumnType('Photo', EyeDataGrid::TYPE_IMAGE, "/images/photos/%LastName%.png"); TYPE_ARRAY -Maps a value to a key in an array -e.g: $db->setColumnType('Gender', EyeDataGrid::TYPE_ARRAY, array('f' => 'Female', 'm' => 'Male')); TYPE_CHECK -Converts a cell to a checkmark when the value is "1", "true", "yes" or value matches 3rd passed value -e.g: $db->setColumnType('Single?', EyeDataGrid::TYPE_CHECK); -e.g: $db->setColumnType('Single?', EyeDataGrid::TYPE_CHECK, 'legs'); TYPE_PERCENT -Converts a value to a percent as a whole number -e.g: $db->setColumnType('Score', EyeDataGrid::TYPE_PERCENT); // Value is already in percent -e.g: $db->setColumnType('Score', EyeDataGrid::TYPE_PERCENT, true); // Value is converted from decimal format when 3rd param is true -e.g: $db->setColumnType('Score', EyeDataGrid::TYPE_PERCENT, true, array('Back' => 'red', 'Fore' => 'black')); // Adds bars whose width represents the percent, colors are specified as 'Back' and 'Fore' TYPE_DOLLAR -Converts a value to the a currency. Always rounded to 2 decimal places -e.g: $db->setColumnType('Price', EyeDataGrid::TYPE_DOLLAR); TYPE_CUSTOM -Convert value to a custom value -e.g: $db->setColumnType('School', EyeDataGrid::TYPE_CUSTOM, 'I go to %CollegeName% in %City%, %Province%'); // Converts a cell to "I go to..". Placeholders are replaced with the value in that row's column TYPE_FUNCTION -Sends a value (or values) to a user specified function -e.g: $db->setColumnType('Password', EyeDataGrid::TYPE_FUNCTION, 'md5', '%Password%'); // Value is sent to the md5 function and return is printed in the cell -e.g: $db->setColumnType('Password', EyeDataGrid::TYPE_FUNCTION, 'make_hash', '%Password%'); // Value is sent to the make_hash user function and return is printed in the cell -e.g: $db->setColumnType('Password', EyeDataGrid::TYPE_FUNCTION, 'generate_key', array('%Username%', '%Password%')); // To pass multiple params to the user function use an array

  • ex1-1.png
  • ex2.png
  • ex3.png
  • ex4.png
  Files folder image Files  
File Role Description
Files folder imageimages (17 files)
Accessible without login Plain text file Class The main data grid class
Plain text file Class Database adapter
Plain text file ex1-ajax.php Example Example w/ Ajax
Plain text file ex1.php Example Example 1
Plain text file ex2.php Example Example 2
Plain text file ex3.php Example Example 3
Plain text file ex4.php Example Example 4
Plain text file ex5.php Example Example 5 - Full featured
Plain text file readme.txt Doc. Readme
Plain text file sample_data.sql Data Sample Data
Plain text file table.css Data Styling

  Files folder image Files  /  images  
File Role Description
  Image file arrow_first.gif Icon
  Image file arrow_first_disabled.gif Icon
  Image file arrow_last.gif Icon
  Image file arrow_last_disabled.gif Icon
  Image file arrow_left.gif Icon
  Image file arrow_left_disabled.gif Icon
  Image file arrow_right.gif Icon
  Image file arrow_right_disabled.gif Icon
  Image file check.gif Icon
  Image file create.png Icon
  Image file delete.png Icon
  Image file edit.png Icon
  Image file filter.gif Icon
  Image file head_bg.gif Icon
  Image file reset.png Icon
  Image file sort_asc.gif Icon
  Image file sort_desc.gif Icon

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:356
This week:455Down
User Ratings User Comments (10)
 All time
I am thrilled! This Class is the one i searched for months.
13 years ago (Gisy1)
Thanks, i try to implement your code with postgres, i have a ...
14 years ago (ptx)
It's a good set of classes to access databases.
15 years ago (Vincent Bevort)
perfect !!!!
15 years ago (kasmeesee)
great! simple and useful.
15 years ago (Supun Perera)
Man you rock good piece of php coding i will be releasing a p...
15 years ago (ahmad nassar)
Very useful.
15 years ago (usbmk3)
Excellent Class.
15 years ago (John Haywood)
Very cool grid
15 years ago (Roberto Marchena)
Very clean code.
15 years ago (Shawn McAllister)