How to set up jqgrid with cakephp

The following are procedures to integrate jqgrid in cakephp

1. Create Table ‘posts’
CREATE TABLE `posts` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`title` VARCHAR(50) NULL DEFAULT NULL,
`body` TEXT NULL,
`created` DATETIME NULL DEFAULT NULL,
`modified` DATETIME NULL DEFAULT NULL,
PRIMARY KEY (`id`)
)
COLLATE=’latin1_swedish_ci’
ENGINE=MyISAM
AUTO_INCREMENT=28;

2. Download this file jqgrid and place it in “app\Vendor”. Your file location will something like this app\Vendor\jqgrid\jqgrid.php

3. Place this function in PostsController.php

	public function render_table(){
		App::import('Vendor', 'jqgrid/jqgrid');
		$oJqgrid = new jqgrid(array('model' => 'Post', 'this'=>$this));
		$response = $oJqgrid->run();
		return new CakeResponse(array('body'=> json_encode($response),'status'=>200));
	}

4. Place this ctp file in view/posts/jqgrid.ctp,

5. Place extract this file inside of webroot/assets
Your folder structure

webroot\assets
                        - jqgrid
                        - jqgrid5
                        - jquery-ui.1.10.4

6. THATS IT!!!

Tags:

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!

You must be logged in to post a comment.