Forum


13:50

30/09/2012

first, sory if my english is not good..
i develop a web using code igniter, and i have trouble when i want to load data to my grid
this is my code: the controller
<?php if(!defined('BASEPATH')) exit ('No direct script access allowed');
class Buku extends CI_Controller{
function __construct(){
parent::__construct();
$this->load->model('m_buku');
}
function index(){
}
function Tampilkan_buku(){
$data = $this->m_buku->tampilkan_buku();
$this->load->view('daftar_buku',json_encode($data));
}
}
/* End of file buku.php */
/* Location: ./application/controllers/buku.php */
the model
<?php if(!defined('BASEPATH')) exit ('No direct script access allowed');
class M_Buku extends CI_Model{
function __construct(){
parent::__construct();
}
function Total_record(){
return $this->db->count_all('tbl_buku');
}
function Tampilkan_buku(){
return $this->db->get('tbl_buku')->result_array();
}
}
/* End of file model_buku.php */
/* Location: ./application/models/model_buku.php */
the views
<body>
<table id="tabel_buku"></table>
<div id="pager2″></div>
</body>
</html>
<script type="text/javascript">
$(document).ready(function(){
jQuery("#tabel_buku").jqGrid({
url: '<?=base_url();?>buku/tampilkan_buku',
datatype: "json",
colNames:['Kode Buku','Judul Buku', 'Pengarang', 'Penerbit','Tahun','Jumlah','Keterangan'],
colModel:[ {name:'kode_buku', index:'kode_buku', width:100},
{name:'judul_buku',index:'judul_buku', width:300},
{name:'pengarang', index:'pengarang', width:100},
{name:'penerbit', index:'penerbit', width:100, align:"right"},
{name:'tahun', index:'tahun', width:80, align:"right"},
{name:'jumlah', index:'jumlah', width:50, align:"right"},
{name:'keterangan',index:'keterangan', width:150, sortable:false}
],
rowNum:20,
rowList:[20,40,60],
pager: '#pager2',
sortname: 'kode_buku',
viewrecords: true,
sortorder: "desc",
caption:"Daftar Buku"
});
jQuery("#tabel_buku").jqGrid('navGrid','#pager2',{edit:false,add:false,del:false});
});
</script>
Most Users Ever Online: 715
Currently Online:
38 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66