Jqgrid + CodeIgniter
- by Ivan
I tried to make jqgrid work with codeigniter, but I could not do it, I only want to show the data from the table in json format... but nothing happens.. but i dont know what i am doing wrong, i cant see the table with the content i am calling.
my controller
class Grid extends Controller
{
public function f()
{
$this->load->model('dbgrid');
$var['grid'] = $this->dbgrid->getcontentfromtable();
foreach($var['grid'] as $row) {
$responce->rows[$i]['id']=$row->id;
$responce->rows[$i]['cell']=array($row->id,$row->id_catalogo);
}
$json = json_encode($responce);
$this->load->view('vgrid',$json);
}
function load_view_grid()
{
$this->load->view('vgrid');
}
}
my model
class Dbgrid extends Model{
function getcontentfromtable()
{
$sql = 'SELECT * FROM anuncios';
$query = $this->db->query($sql);
$result = $query->result();
return $result;
}
}
my view(script)
$(document).ready(function() {
jQuery("#list27").jqGrid({
url:'http://localhost/sitio/index.php/grid/f',
datatype: "json",
mtype: "post",
height: 255,
width: 600,
colNames:['ID','ID_CATALOGO'],
colModel:[
{name:'id',index:'id', width:65, sorttype:'int'},
{name:'id_catalogo',index:'id_catalogo', sorttype:'int'}
],
rowNum:50,
rowTotal: 2000,
rowList : [20,30,50],
loadonce:true,
rownumbers: true,
rownumWidth: 40,
gridview: true,
pager: '#pager27',
sortname: 'item_id',
viewrecords: true,
sortorder: "asc",
caption: "Loading data from server at once"
});
});
hope someone help me