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