data base file :-
CREATE TABLE IF NOT EXISTS `countries` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`country_name` varchar(150) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=102 ;
–
– Dumping data for table `countries`
–
INSERT INTO `countries` (`id`, `country_name`) VALUES
(1, ‘Drum Island’),
(2, ‘Shiropp Village’),
(3, ‘Kingdom Alabasta’),
(4, ‘Fuschia Village’),
(5, ‘Water Seven’),
(6, ‘Island of Ohara’);
– ——————————————————–
–
– Table structure for table `users`
–
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`fullname` varchar(150) NOT NULL,
`email` varchar(100) NOT NULL,
`country_id` int(11) NOT NULL DEFAULT ’1′,
`occupation` varchar(150) NOT NULL,
`birthdate` date NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=26 ;
–
– Dumping data for table `users`
–
INSERT INTO `users` (`id`, `fullname`, `email`, `country_id`, `occupation`, `birthdate`) VALUES
(1, ‘Roronoa Zoro’, ‘roronoa-zoro@strawhat.com’, 1, ‘Straw Hat Swordman’, ’1990-07-26′),
(2, ‘Sanji Black Leg’, ‘sanji@strawhat.com’, 1, ‘Straw Hat Chef’, ’1988-02-11′),
(3, ‘Nico Robin’, ‘nico.robin@strawhat.com’, 1, ‘Straw Hat Archeologist ‘, ’1986-12-25′),
(4, ‘Brook’, ‘brook@strawhat.com’, 1, ‘Straw Hat Musician’, ’1945-04-03′),
(5, ‘Monkey D Luffy’, ‘luffy@strawhat.com’, 1, ‘Straw Hat Captain’, ’1989-07-27′),
(6, ‘Nami’, ‘nami@strawhat.com’, 1, ‘Straw Hat Navigator’, ’1987-10-29′),
(7, ‘Red Haired Shanks’, ‘shanks@redhair.com’, 1, ‘Red Haired Captain’, ’1972-03-02′),
(8, ‘Tony Tony Chopper’, ‘chopper@strawhat.com’, 1, ‘Straw Hat Docter’, ’1995-03-15′),
(9, ‘Usopp ‘, ‘usopp@strawhat.com’, 1, ‘Straw Hat Marksman’, ’1989-04-01′),
(10, ‘Edward Newgate Whitebeard’, ‘edward@whitebeard.com’, 1, ‘Whitebeard Captain’, ’1955-03-23′),
(11, ‘Nefertari Vivi’, ‘vivi@alabasta.com’, 1, ‘Princess of Alabasta ‘, ’1989-11-21′),
(12, ‘Franky Cutty Flam’, ‘franky@strawhat.com’, 1, ‘Straw Hat Shipwright’, ’1971-07-29′),
(13, ‘Donquixote Doflamingo’, ‘doflamingo@shinchibukai.com’, 1, ‘Shinchibukai’, ’1980-09-08′),
(14, ‘Bartholomew Kuma’, ‘b_kuma@shinchibukai.com’, 1, ‘Shinchibukai’, ’1977-12-31′),
(15, ‘Jimbei’, ‘jimbei@shinchibukai.com’, 1, ‘Shinchibukai’, ’1988-03-29′),
(16, ‘Juracule ”Hawk Eye” Mihawk’, ‘mhawk@shinchibukai.com’, 1, ‘Shinchibukai’, ’1981-09-16′),
(17, ‘Gecko Moria’, ‘g_moria@shinchibukai.com’, 1, ‘Shinchibukai’, ’1965-01-06′),
(18, ‘Sir Crocodile’, ‘croc@shinchibukai.com’, 1, ‘Shinchibukai’, ’1976-10-07′),
(19, ‘Marshall ”Blackbeard” D. Teach’, ‘dteach.blackbeard@shinchibukai.com’, 1, ‘Shinchibukai’, ’1958-08-07′),
(20, ‘Gensui Sengoku’, ‘sengoku@marinehq.com’, 1, ‘Fleet Admiral’, ’1977-07-14′),
(21, ‘Smoker’, ‘smoker@marinehq.com’, 1, ‘Commodore’, ’1978-10-12′),
(22, ‘Ensign Tashigi’, ‘e.tashigi@marinehq.com’, 1, ‘Smoker Partner’, ’1986-01-22′),
(23, ‘Aokiji’, ‘aokiji@marinehq.com’, 1, ‘Admiral’, ’1971-02-25′),
(24, ‘Taisho’, ‘taisho@marinehq.com’, 1, ‘Admiral’, ’1976-05-22′),
(25, ‘Rob Lucci’, ‘rob.lucci@cp9.com’, 1, ‘CP9 Member’, ’1985-04-25′);
Controller file : -
<?php
class User extends Controller {
public function __construct()
{
parent::Controller();
}
public function index()
{
$this->load->view(‘user/index’);
}
public function ext_get_all()
{
$start = isset($_REQUEST['start']) ? $_REQUEST['start'] : 0;
$limit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : 10;
$this->db->select(‘users.*, countries.country_name’);
$this->db->from(‘users’);
$this->db->join(‘countries’,
‘countries.id = users.country_id’);
$this->db->limit($limit, $start);
$query = $this->db->get();
$results = $this->db->count_all(‘users’);
$arr = array();
foreach ($query->result() as $obj)
{
$arr[] = $obj;
}
echo ‘{success:true,results:’. $results .
‘,rows:’.json_encode($arr).’}';
}
}
view file :-
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<link rel=”stylesheet” type=”text/css” href=”<?php echo base_url(); ?>assets/js/ext/resources/css/ext-all.css”/>
<script type=”text/javascript” src=”<?php echo base_url(); ?>assets/js/ext/adapter/ext/ext-base.js”></script>
<script type=”text/javascript” src=”<?php echo base_url(); ?>assets/js/ext/ext-all.js” ></script>
<script type=”text/javascript”>
var BASE_URL = ‘<?php echo base_url(); ?>’ + ‘index.php/’;
var BASE_PATH = ‘<?php echo base_url(); ?>’;
var BASE_ICONS = BASE_PATH + ‘assets/icons/’;
Ext.onReady(function() {
var strUsers = new Ext.data.Store({
reader: new Ext.data.JsonReader({
fields: [
'id', 'fullname', 'email', 'country_id',
'country_name', 'occupation', 'birthdate'
],
root: ‘rows’, totalProperty: ‘results’
}),
proxy: new Ext.data.HttpProxy({
url: BASE_URL + ‘user/ext_get_all’,
method: ‘POST’
})
});
var tbUsers = new Ext.Toolbar({
items:[{
text: 'Add',
icon: BASE_ICONS + 'user_add.png'
}, '-', {
text: 'Delete',
icon: BASE_ICONS + 'user_delete.png'
}]
});
var cbGrid = new Ext.grid.CheckboxSelectionModel();
var gridUsers = new Ext.grid.GridPanel({
frame: true, border: true, stripeRows: true, sm: cbGrid,
store: strUsers, loadMask: true, title: ‘Users List’,
style: ‘margin:0 auto;’, height: 330, width: 722,
columns: [
cbGrid, {
header: "Fullname",
dataIndex: 'fullname',
width: 180
}, {
header: "Email",
dataIndex: 'email',
width: 180
}, {
header: "Country",
dataIndex: 'country_name',
width: 120
}, {
header: "Occupation",
dataIndex: 'occupation',
width: 120
}, {
header: "Birth",
dataIndex: 'birthdate',
width: 80,
renderer : Ext.util.Format.dateRenderer('d/m/Y')
}
],
tbar: tbUsers,
bbar: new Ext.PagingToolbar({
pageSize: 10,
store: strUsers,
displayInfo: true
})
});
gridUsers.render(‘divgrid’);
strUsers.load();
});
</script>
<style type=”text/css”>
#divgrid {
background: #e9e9e9;
border: 1px solid #d3d3d3;
margin: 20px;
padding: 20px;
}
</style>
<title>ExtJS CodeIgniter </title>
</head>
<body>
<div id=”divgrid”></div>
</body>
</html>
Manage & Developed By Sptechnolab.com