Foros del Web » Programando para Internet » Jquery »

jqGrid Tablas Relacionadas

Estas en el tema de jqGrid Tablas Relacionadas en el foro de Jquery en Foros del Web. Buenas tardes, Estoy retomando php y javasvript después de mucho tiempo, y he usado el pluging jqGrid, para crear las grillas. Lo que he usado ...
  #1 (permalink)  
Antiguo 27/12/2018, 10:08
Avatar de avielo  
Fecha de Ingreso: junio-2008
Ubicación: Córdoba (España)
Mensajes: 111
Antigüedad: 15 años, 10 meses
Puntos: 2
jqGrid Tablas Relacionadas

Buenas tardes,

Estoy retomando php y javasvript después de mucho tiempo, y he usado el pluging jqGrid, para crear las grillas. Lo que he usado bien, para editar altas y modificar sin problema. El problema me lo encuentro, cuando quiero usar una tabla con datos relacionados.

La tabla es las cuotas de unos afiliados, que estan relacionadas con los propios afiliados. Para editar uso el formulario de jqgrid. He intentado poner un select, para que elijan el afiliado, pero no me carga los datos.
Le he dado muchas vueltas y no se que se me puede estar pasando. Decir que ando un poco oxidado. Perdón si hay fallos muy gordos.

Os pongo my código.


Index.html:

Código:
<script type="text/javascript">
			$(document).ready(function(){
		   		jQuery("#tblCuotas").jqGrid({
					url:'cargaCuotas.php',
			   		editurl: "editCuotas.php",
					datatype: 'json',
					mtype: 'POST',
					colModel:[
						{
							label: 'ID Cuota',
							name: 'idCuota',
							index:'idCuota',
							width: 50,
							key: true,
							editable: true,
							hidden: true
						},
						{
							label: 'Num. Cuota',
							name: 'NumD',
							index:'NumD',
							width: 50,
							editable: true,
							editoptions : { required: true, placeholder: "Número de Cuota requieredo"}
						},
						{
							label: 'Num. Afiliado',
							name: 'NumAfiliado',
							index:'NumAfiliado',
							width: 150,
							editable: true,
							edittype: 'select',
							formatter:'select',
							editoptions : { dataurl: 'afiliadosSelect.php' },
							editrules : { required: true, placeholder: "Número de Cuota Afiliado"}
						},
						{
							label: 'Nombre',
							name: 'NOMBRE',
							index:'NOMBRE',
							width: 300,
							editable: true
						},
						{
							label: 'Cuota',
							name: 'CUOTA',
							index:'CUOTA',
							width: 150,
							editable: true,
							editoptions : { required: true, placeholder: "Importe de la cuota requieredo"}
						},
						{
							label: 'Mes',
							name: 'MES',
							index:'MES',
							width: 120,
							editable: true,
							editoptions : { }
						},
						{
							label: 'Año',
							name: 'ANNO',
							index:'ANNO',
							width: 50,
							editable: true,
							editoptions : { }
						},
						{
							label: 'Pago',
							name: 'PAGO',
							index:'PAGO',
							width: 50,
							editable: true,
							edittype: 'select',
							editoptions : { value: "Y:SI;N:NO" }
						},
						{
							label: 'Forma Pago',
							name: 'FormaPago',
							index:'FormaPago',
							width: 100,
							editable: true,
							editoptions : { }
						}
						
					],	
			   		loadonce: false,
			   		width: window.innerWidth-20,
			   		height: window.innerHeight-150,
					pager: '#paginacion',
					rowNum: 50,
					rowList:[50,100,150],
					sortname: 'NumD',
					sortorder: 'asc',
					viewrecords: true,
					caption: 'CUOTAS'
				});   
				
				
				jQuery("#tblCuotas").jqGrid('navGrid','#paginacion',
					{edit:true,add:true,del:true},
					// options for the Edit Dialog
											   
					{
						html5Check :  true,
						editCaption: "The Edit Dialog",
						recreateForm: true,
						checkOnUpdate : true,
						checkOnSubmit : true,
						closeAfterEdit: true,
						reloadAfterEdit:true,
						reloadAfterSubmit:true,
						errorTextFormat: function (data) {
                        	return 'Error: ' + data.responseText
                    	},
						buttons : [
							{
								side : "right",
								text : "Afiliado",
								position : "first",
								click : function( form, params, event) {
									alert("Custom action in search form");
								}
							}
							]
                		},
					
											
					// options for the Add Dialog
					{
						closeAfterAdd: true,
						html5Check : true,
						recreateForm: true,
						errorTextFormat: function (data) {
							return 'Error: ' + data.responseText
						}
					},
					// options for the Delete Dailog
					{
						errorTextFormat: function (data) {
							return 'Error: ' + data.responseText
						}
					});
			
			});


		</script>
afiliadosSelect.php:

Código:
<?php
    include "../class/tAfiliados.php";

	echo '<script>alert("Custom action in search form");</script>';
	$oAfiliado = new tAfiliados(1, 0, 1, 1);
	$respuesta = $oAfiliado->selectAfiliados();
	

    echo $respuesta;
?>
tAfiliados.php:

Código:
<?php

include 'tMySQL.php';
 

class tAfiliados
{
	
	public function selectAfiliados()
	{
		$oMySQL = new tMySQL();
				
		if ($oMySQL->bConnect)
		{
			$cSQL ="SELECT COUNT(*) AS cuantos FROM afiliados WHERE borrado=0";	
			$this->fila = $oMySQL->countQuery($cSQL);
			$this->cuantos = $this->fila['cuantos'];
			
			$query = "SELECT idAfiliado, NumAfiliado, NOMBRE FROM afiliados WHERE borrado=0 ORDER BY NOMBRE"; 
			$result = $oMySQL->GetQuery($query);

			$response ='<select>';
			$i=0;
			while( $i <= $this->cuantos ) {
				$response .= '<option value="'.$result[$i]['NumAfiliado'].'">'.$result[$i]['NOMBRE'].'</option>';
				$i++;
			}
			$response .= '</select>';
			
		}
				
		$oMySQL->Close();	
		return $response;
	}
}

?>
Un saludo y muchas gracias por adelantado.
__________________
http://www.avielomarketing.com
  #2 (permalink)  
Antiguo 08/01/2019, 10:53
Avatar de avielo  
Fecha de Ingreso: junio-2008
Ubicación: Córdoba (España)
Mensajes: 111
Antigüedad: 15 años, 10 meses
Puntos: 2
Respuesta: jqGrid Tablas Relacionadas

Nadie me puede ayudar???
__________________
http://www.avielomarketing.com

Etiquetas: javascript, jqgrid, php, relacionadas, tablas
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 07:27.