Created: 09 Jan 2010
By: The-Di-Lab
Email: thedilab@gmail.com
Social:
Thank you for purchasing my script. If you have any questions that are beyond the scope of this help file, please feel free to contact me via my email.
Please also follow my twitter account to get future updates of this script.
Thank you very much!
CREATE TABLE IF NOT EXISTS `crud_sample` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(250) NOT NULL, `email` varchar(250) NOT NULL, `is_admin` tinyint(1) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;
<?php include 'crud/grid_object.php';
$gridObject = new GridObject();
$gridObject->setDbTable('crud_sample');
$gridObject->setPerPage(5); ?>
<link type="text/css" rel="stylesheet" href="crud/webroot/css/jquery-ui-1.8.7.custom.css" /> <script type="text/javascript" src="crud/webroot/js/jquery-1.4.4.min.js"></script> <script type="text/javascript" src="crud/webroot/js/jquery-ui-1.8.7.custom.min.js"></script> <script type="text/javascript" src="crud/webroot/js/crud.js"></script> <link type="text/css" rel="stylesheet" href="crud/webroot/css/crud.css" />
<div style="width: 100%; margin:auto; text-align: center;"> <?php $gridObject->render(); ?> </div>
<?php include 'crud/grid_object.php'; $gridObject = new GridObject(); $gridObject->setDbTable('crud_sample'); $gridObject->setPerPage(5); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link type="text/css" rel="stylesheet" href="crud/webroot/css/jquery-ui-1.8.7.custom.css" /> <script type="text/javascript" src="crud/webroot/js/jquery-1.4.4.min.js"></script> <script type="text/javascript" src="crud/webroot/js/jquery-ui-1.8.7.custom.min.js"></script> <script type="text/javascript" src="crud/webroot/js/crud.js"></script> <link type="text/css" rel="stylesheet" href="crud/webroot/css/crud.css" /> </head> <body> <div style="width: 100%; margin:auto; text-align: center;"> <?php $gridObject->render(); ?> </div> </body> </html>
To set column's title, call setTitle(), and pass array parameter: array(DB_FIELD_NAME=>array('name'=>CUSTOMIZE_NAME)).
$gridObject->setTitle(array( 'id'=>array('name'=>'ID'), 'name'=>array('name'=>'NAME'), 'email'=>array('name'=>'EMAIL'), 'is_admin'=>array('name'=>'ADMIN') ));
To style th tag, for example, set its width, call setTitle(), and pass array parameter: array(DB_FIELD_NAME=>array('style'=>STYLE)).
$gridObject->setTitle(array( 'id'=>array('style'=>'width:100px;'), 'name'=>array('style'=>'width:100px;'), 'email'=>array('style'=>'width:100px;'), 'is_admin'=>array('style'=>'width:100px;') ));
To disable sorting on a particular column, call setTitle(), and pass array parameter: array(DB_FIELD_NAME=>array('sort'=>TRUE/FALSE)).
$gridObject->setTitle(array( 'id'=>array('sort'=>false), 'name'=>array('sort'=>false), 'email'=>array('sort'=>false), 'is_admin'=>array('sort'=>false) ));
If you want to customize column title name, style its th tag and disable sorting all at once. You can do so by calling setTitle and pass in combined array parameter.
$gridObject->setTitle(array( 'id'=>array('name'=>'ID','style'=>'width:100px;','sort'=>false), 'name'=>array('name'=>'NAME','style'=>'width:100px;','sort'=>false), 'email'=>array('name'=>'EMAIL','style'=>'width:100px;','sort'=>false), 'is_admin'=>array('name'=>'ADMIN','style'=>'width:100px;','sort'=>false) ));
If you want to disable any CRUD operations. you can call setActions() and pass in parameter:
array('read'=>TRUE/FALSE,'delete'=>TRUE/FALSE,'update'=>TRUE/FALSE,'create'=>TRUE/FALSE)
$gridObject->setActions(array('read'=>true,'delete'=>false,'update'=>false,'create'=>false));
To set the overall table width, you need to modify a css file which is located at "crud/webroot/css/crud.css". And edit width value of #crud-container.
#crud-container { margin: 50px auto 0px auto; width: 600px; position: relative; }
CRUD Gen is powered by jQuery UI CSS framework, to use any jQuery UI CSS theme. Simply go to http://jqueryui.com/themeroller/.
And download any UI theme. Then inside header section of your page, instead of using the default "crud/webroot/css/jquery-ui-1.8.7.custom.css" and "crud/webroot/js/jquery-ui-1.8.7.custom.min.js",
change it to your downloaded theme css and js files.
Change these two files
<link type="text/css" rel="stylesheet" href="crud/webroot/css/jquery-ui-1.8.7.custom.css" /> <script type="text/javascript" src="crud/webroot/js/jquery-ui-1.8.7.custom.min.js"></script>To
<link type="text/css" rel="stylesheet" href="crud/webroot/css/your-downloaded-jquery-ui.custom.css" /> <script type="text/javascript" src="crud/webroot/js/your-downloaded-jquery-ui.custom.min.js"></script>
If your database table is having a different primary key from default primary key "id", you can change primary key by calling function setPrimaryKey.
$gridObject->setPrimaryKey($your-primary-key);
If you want to hide a specific column from user, for example primary key field, you can do so by calling setTitle(), and pass array parameter: array(DB_FIELD_NAME=>FALSE).
$gridObject->setTitle(array('id'=>false));
Start from version 1.2, you are able to enable ajax live search on a particular column. You can do so by calling setTitle and pass in parameter(array('search'=>true));
$gridObject->setTitle(array( 'id'=>array('search'=>true), 'name'=>array('search'=>true), 'email'=>array('search'=>true), 'is_admin'=>array('search'=>true) ));
Once again, thank you so much for purchasing this script. As I said at the beginning, I'd be glad to help you if you have any questions relating to this script. No guarantees, but I'll do my best to assist. And do not forget to follow my twitter to get future updates.
The-Di-Lab