0
CodeIgniterとjqGridを使用すると問題が発生します。グリッドは正しいデザインですが、データをグリッドにロードしません。表示されるメッセージは「未定義」です。CodeIgniter jqGrid undefined
<head>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/themes/dark-hive/jquery-ui.css" type="text/css" rel="stylesheet"/>
<link href="http://static.jquery.com/ui/css/demo-docs-theme/ui.theme.css" type="text/css" rel="stylesheet"/>
<link type="text/css" href="<?php echo base_url()?>asset/jqgrid/css/ui.jqgrid.css" rel="stylesheet" />
<link type="text/css" href="<?php echo base_url()?>asset/jqgrid/css/jquery.searchFilter.css" rel="stylesheet" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.min.js" type="text/javascript"></script>
<script src="<?php echo base_url(); ?>'asset/jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="<?php echo base_url(); ?>asset/jqgrid/js/jquery.jqGrid.js" type="text/javascript"></script>
<script src="<?php echo base_url(); ?>asset/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>
<title>Jqgrid</title>
</head>
<body>
<script type="text/javascript">
jQuery().ready(function(){
jQuery("#list").jqGrid({
url:'<?php echo base_url().'index.php/jqgrid/example'?>',
mtype : "post",
datatype: "json",
colNames:['Inv No','Date', 'Amount','Tax','Total','Notes'],
colModel :[
{name:'invid', index:'invid', width:20},
{name:'invdate', index:'invdate', width:90, align:'center',editable:true, formatter:'date',editrules: { required: true, date:true}, formatoptions:{srcformat:'Y-m-d', newformat:'m/d/Y'}},
{name:'amount', index:'amount', width:80, align:'center',editable:true,edittype:'text'},
{name:'tax', index:'tax', width:80, align:'center',editable:true,edittype:'text'},
{name:'total', index:'total', width:80, align:'center',editable:true, edittype:'text'},
{name:'note', index:'note', width:150, align:'center', sortable:false,editable:true,edittype:'text'}
],
rowNum:10,
width: 800,
height: 200,
rowList:[10,20,30,40,50,60,70],
pager: '#gridpager',
sortname: 'invid',
viewrecords: true,
caption:"CLientes"
}).navGrid(
'#gridpager',
{view:true,edit:true,add:true,del:true,search:true},
{closeAfterEdit:true,modal:true}, // use default settings for edit
{}, // use default settings for add
{}, // delete instead that del:false we need this
{}, // enable the advanced searching
{closeOnEscape:true} /* allow the view dialog to be closed when user press ESC key*/
);
});
</script>
<table id="list"></table>
<div id="gridpager"></div>
</body>
class jqgrid extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->helper(array('url'));
$this->load->model('cliente');
$this->load->database();
}
function index()
{
$this->load->view('jqgrid/home');
}
function example()
{
$hal = isset($_POST['page'])?$_POST['page']:1;
$batas = isset($_POST['rows'])?$_POST['rows']:10;
$sidx = isset($_POST['sidx'])?$_POST['sidx']:'invid';
if(!$sidx) $sidx=1;
$q = $this->cliente->cargar();
$hitung = count($q);
if($hitung > 0) {
$total_hal = ceil($hitung/$batas);
} else {
$total_hal = 0;
}
if ($hal > $total_hal) $hal=$total_hal;
$start = $batas*$hal - $batas;
$start = ($start < 0) ? 0 : $start;
$data->page = $hal;
$data->total = $total_hal;
$data->records = $hitung;
$i=0;
foreach($q->result() as $row) {
$data->rows[$i]['id']=$row->invid;
$data->rows[$i]['cell']=array($i+1,$row->invdate,$row->amount,$row->tax,$row->total,$row->note);
$i++;
}
echo json_encode($data);
}
}
回答ありがとうございますが問題は解決策ではありません – user1037726
@ user1037726:申し訳ありませんが、「問題の検索ソリューションではない」という意味を理解できていませんか? – Oleg
http://pastebin.com/Hg5WNic0 – user1037726