Aqui les dejo el código de Ejemplo:
<script language="javascript">
//////////// INICIO DE FACTURAS ///////////////////
jQuery("#list10").jqGrid({
url:'<?php echo $this->createUrl('catFacturaImpuestos/getFacturaImpuestos'); ?>',
datatype: "json",
colNames:[/*'Acción',*/'Id','Recepción Factura', 'Nombre Agente', 'Número Factura','Fecha Factura','Monto','Moneda','Observaciones'],
colModel:[
//{name: 'myac', search:false, width:50, fixed:true, sortable:false, resize:false, formatter:'actions', formatoptions:{keys:true}},
{name:'factura_impuestos_id',index:'factura_impuestos_id', search:false, width:55,align:"center"},
{name:'fecha_recepcion_factura',index:'fecha_recepcion_factura', width:130},
{name:'nombre_agente_aduanal',index:'nombre_agente_aduanal', width:100,editrules:{required:true},formoptions:{elmsuffix:'*'}},
{name:'numero_factura',index:'fecha_factura_fletes', datefmt:'Y-m-d', width:105, align:"center",editoptions: {
dataInit: function (elem) {
$(elem).mask("9999-99-99",
{
completed:function()
{
this.val();
}
}
);
}},
formoptions:{elmsuffix:'*'},editrules:{required:true, date:true}
},
{name:'fecha_factura',index:'fecha_factura', align:"right", width:80,editrules:{required:true},formoptions:{elmsuffix:'*'}},
{name:'monto',index:'monto',width:60,align:"center"},
{name:'moneda',index:'moneda',width:60,editable:false},
{name:'observaciones',index:'observaciones',width:60,editable:true},
],
rowNum:4,
rowList:[10,20,30],
pager: '#pager10',
sortname: 'factura_impuestos_id',
viewrecords: true,
sortorder: "desc",
caption: "Listado de Facturas Impuestos",
width: 450,
shrinkToFit: false,
editurl:'<?php echo $this->createUrl('catFacturaImpuestos/AsignaFacturaPedimentos') ?>',
height: 100,
onSelectRow: function(ids) {
if(ids == null) {
ids=0;
if(jQuery("#list10").jqGrid('getGridParam','records') >0 )
{
var cons=jQuery("#list10").getCell(ids,'numero_factura');
document.getElementById('X_Numero_Factura').value=cons;
document.getElementById('X_Factura_id').value=ids;
///
jQuery("#list10_d").jqGrid('setGridParam',{url:"scripts/getFacturasImpuestosPedimentos.php?q=1&consecutivo="+ids,page:1}).trigger('reloadGrid');
///
jQuery("#list10_d").jqGrid('setCaption',"Detalle Factura Impuestos: "+cons)
}
} else {
var cons=jQuery("#list10").getCell(ids,'numero_factura');
document.getElementById('X_Numero_Factura').value=cons;
document.getElementById('X_Factura_id').value=ids;
///
jQuery("#list10_d").jqGrid('setGridParam',{url:"scripts/getFacturasImpuestosPedimentos.php?q=1&consecutivo="+ids,page:1}).trigger('reloadGrid');
///
jQuery("#list10_d").jqGrid('setCaption',"Detalle Factura Impuestos: "+cons)
}
}
});
jQuery("#list10").jqGrid('navGrid','#pager10',{add:false,edit:false,del:false},
{width:400},
{width:400,editData:{xconsecutivo_trafico:function(){return document.getElementById('X_Consecutivo').value;}}},
{width:400,editData:{xconsecutivo_trafico:function(){return document.getElementById('X_Consecutivo').value;}}}
);
y Aqui el Action que rcupera los datos
public function actiongetFacturaImpuestos()
{
$criteria = new CDbCriteria;
$criteria->order = $_GET['sidx'].' '.$_GET['sord'];
$searchOn = $_REQUEST['_search'];
$fld = $_REQUEST['searchField'];
$fldata = $_REQUEST['searchString'];
$foper = $_REQUEST['searchOper'];
$criteria->condition = $wh;
$dataProvider=new CActiveDataProvider('CatFacturaImpuestos', array(
'criteria'=>$criteria,
'pagination'=>array(
'pageSize'=>$_GET['rows'],
'currentPage'=>$_GET['page']-1,
),
));
$responce->page = $_GET['page'];
$responce->records = $dataProvider->getTotalItemCount();
$responce->total = ceil($responce->records / $_GET['rows']);
$rows = $dataProvider->getData();
foreach ($rows as $i=>$row)
{
$responce->rows[$i]['id'] = $row['factura_impuestos_id'];
$responce->rows[$i]['cell'] = array(//'',
$row->factura_impuestos_id,
$row->fecha_recepcion_factura,
$row->nombre_agente_aduanal,
$row->numero_factura,
$row->fecha_factura,
$row->monto,
$row->moneda
);
}
echo json_encode($responce);
}