Foros del Web » Programando para Internet » Jquery »

(ayuda)altas y bajas con jquery data tables

Estas en el tema de (ayuda)altas y bajas con jquery data tables en el foro de Jquery en Foros del Web. holas a todos como estan soy nuevo en la programacion asique como muchos aprendo lo que puedo de internet, paprendi a usar un poco el ...
  #1 (permalink)  
Antiguo 10/09/2013, 11:07
 
Fecha de Ingreso: septiembre-2013
Ubicación: chile
Mensajes: 1
Antigüedad: 10 años, 7 meses
Puntos: 0
(ayuda)altas y bajas con jquery data tables

holas a todos como estan soy nuevo en la programacion asique como muchos aprendo lo que puedo de internet, paprendi a usar un poco el pluyin data tables esta muy facil de usar pero no se como podria modificar los datos ya que cuando llena la tabla la llena a travez de una "arreglo" de que forma podria agregarle altas y bajas la verdad que keda muy bonito con el css les dejo el codigo de ante mano gracias
index.html
Código:
<!doctype html>
<html lang="es">
<head>
	<meta charset="UTF-8">
	<title>control tecnicos</title>
	<link href="css/style.css" type="text/css" rel="stylesheet"/>
	<link href="css/jquery-ui.css" type="text/css" rel="stylesheet"/>
	<link href="css/datatables.css" type="text/css" rel="stylesheet"/>
	
	<script src="js/jquery.js"></script>
	<script src="js/jquery-ui.js"></script>
	<script src="js/datatables.js"></script>
	<script src="js/functions.js"></script>
</head>
<body>
	<header>
		<h1>Control Tecnicos </h1>
	</header>
	<section>
		<table>
			<thead>
				<tr>
					<th>Rut</th>
					<th>Nombres</th>
					<th>Apellidos</th>
                    <th>Correo</th>
                    <th>Titulo</th>
                    <th>Celular</th>
                    
			</thead>
		</table>
	</section>
	<footer></footer>
</body>
</html>
carpeta js
datatables, jquery, jqueryUI [URL="https://mega.co.nz/#!XVc2gDDS!S1m0CVKSQ0735xN90B7ykENOEoVEqp84pDGv7PI vmZ0"]https://mega.co.nz/#!XVc2gDDS!S1m0CVKSQ0735xN90B7ykENOEoVEqp84pDGv7PI vmZ0[/URL]

function
Código:
$(document).ready(function() {
	
	$.ajax({
			url: './include/process.php',
			type: 'post',
			data: { tag: 'getData'},
			dataType: 'json',
			success: function (data) {
				if (data.success) {
					$.each(data, function (index, record) {
						if ($.isNumeric(index)) { 
							var row = $("<tr />");
							$("<td />").text(record.Rut).appendTo(row);
							$("<td />").text(record.Nombres).appendTo(row);
							$("<td />").text(record.Apellidos).appendTo(row);
							$("<td />").text(record.Correo).appendTo(row);
							$("<td />").text(record.Titulo).appendTo(row);
							$("<td />").text(record.Celular).appendTo(row);
							
							
							
							row.appendTo("table");
						}
					})
				}

				$('table').dataTable({
					"bJQueryUI": true,
					"sPaginationType": "full_numbers",
					
					
					
		
					
					
				})
			}
		});
})
carpeta include:
connect.php
Código:
<?php
	return new PDO('mysql:host=localhost;dbname=alsur','root','');
?>
process.php
Código:
<?php
	if (isset($_POST['tag'])) {
		try {
			$conn = require_once 'connect.php';

			$sql = "SELECT *
FROM tecnicosx
WHERE priv = 'tecnico'";
			$result = $conn->prepare($sql) or die ($sql);

			if (!$result->execute()) return false;

			if ($result->rowCount() > 0) {
				$json = array();
				while ($row = $result->fetch()) {
					$json[] = array(
						'Rut' => $row['rut'],
						'Nombres' =>$row['nombres'],
						'Apellidos' => $row['apellidos'],
						'Correo' => $row['correo'],
						'Titulo' => $row['titulo'],
						'Celular' => $row['celular'],
						'Editar' => $row['id'],
						'Borrar' => $row['id']
					);
				}

				$json['success'] = true;
				echo json_encode($json);
			}
		} catch (PDOException $e) {
			echo 'Error: '. $e->getMessage();
		}
	}

?>
carpeta css
[URL="https://mega.co.nz/#!KVlmGITQ!MTFyiW61iMypIH4ceNwnliV2ProddYuAtWv3Fii gkdg"]https://mega.co.nz/#!KVlmGITQ!MTFyiW61iMypIH4ceNwnliV2ProddYuAtWv3Fii gkdg[/URL]

base de datos
Código:
-- phpMyAdmin SQL Dump
-- version 3.5.1
-- http://www.phpmyadmin.net
--
-- Servidor: localhost
-- Tiempo de generación: 10-09-2013 a las 16:34:36
-- Versión del servidor: 5.5.24-log
-- Versión de PHP: 5.4.3

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Base de datos: `alsur`
--

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `herramientas`
--

CREATE TABLE IF NOT EXISTS `herramientas` (
  `id_herramientas` int(11) NOT NULL AUTO_INCREMENT,
  `nombre_herr` varchar(16) COLLATE utf8_bin NOT NULL,
  `estado_herr` varchar(45) COLLATE utf8_bin NOT NULL,
  `num_serie` varchar(45) COLLATE utf8_bin NOT NULL,
  `tecnicosx_id` int(11) NOT NULL,
  PRIMARY KEY (`id_herramientas`),
  KEY `fk_herramientas_tecnicosx_idx` (`tecnicosx_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=4 ;

--
-- Volcado de datos para la tabla `herramientas`
--

INSERT INTO `herramientas` (`id_herramientas`, `nombre_herr`, `estado_herr`, `num_serie`, `tecnicosx_id`) VALUES
(1, 'notebook', 'operativa', '156546464', 7),
(2, 'alicate', 'malo', 's/n', 7),
(3, 'wevo', 'sdsd', 'sdsdsdsd', 7);

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `orden_servicio`
--

CREATE TABLE IF NOT EXISTS `orden_servicio` (
  `id_orden` int(11) NOT NULL AUTO_INCREMENT,
  `sk_orden` varchar(10) COLLATE utf8_bin NOT NULL,
  `comentario` varchar(100) COLLATE utf8_bin NOT NULL,
  `direccion_almacenado` varchar(100) COLLATE utf8_bin NOT NULL,
  `tecnicosx_id` int(11) NOT NULL,
  PRIMARY KEY (`id_orden`),
  KEY `fk_orden_servicio_tecnicosx1_idx` (`tecnicosx_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `permiso`
--

CREATE TABLE IF NOT EXISTS `permiso` (
  `id_permiso` int(11) NOT NULL AUTO_INCREMENT,
  `fecha_solicitud` date NOT NULL,
  `fecha_permiso` date NOT NULL,
  `justificacion` varchar(100) COLLATE utf8_bin NOT NULL,
  `estado` varchar(8) COLLATE utf8_bin NOT NULL,
  `tecnicosx_id` int(11) NOT NULL,
  PRIMARY KEY (`id_permiso`),
  UNIQUE KEY `id_permiso_UNIQUE` (`id_permiso`),
  KEY `fk_permiso_tecnicosx1_idx` (`tecnicosx_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `tecnicosx`
--

CREATE TABLE IF NOT EXISTS `tecnicosx` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `rut` varchar(16) COLLATE utf8_bin NOT NULL,
  `titulo` varchar(64) COLLATE utf8_bin NOT NULL,
  `camisa` varchar(2) COLLATE utf8_bin NOT NULL,
  `pantalon` varchar(2) COLLATE utf8_bin NOT NULL,
  `calzado` int(11) NOT NULL,
  `nombres` varchar(45) COLLATE utf8_bin NOT NULL,
  `apellidos` varchar(45) COLLATE utf8_bin NOT NULL,
  `correo` varchar(45) COLLATE utf8_bin NOT NULL,
  `celular` int(11) NOT NULL,
  `usuario` varchar(8) COLLATE utf8_bin NOT NULL,
  `contrasena` varchar(8) COLLATE utf8_bin NOT NULL,
  `priv` varchar(45) COLLATE utf8_bin NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `rut_UNIQUE` (`rut`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=20 ;

--
-- Volcado de datos para la tabla `tecnicosx`
--

INSERT INTO `tecnicosx` (`id`, `rut`, `titulo`, `camisa`, `pantalon`, `calzado`, `nombres`, `apellidos`, `correo`, `celular`, `usuario`, `contrasena`, `priv`) VALUES
(7, '16036099-2', 'analista programador de sistemas computacionales', '', '', 0, 'guillermo rodrigo', 'herrera jara', '[email protected]', 61700985, '', '', 'tecnico'),
(8, '13104870-K', '-', '', '', 0, 'David', 'Rodriguez', '[email protected]', 61701012, '', '', 'tecnico'),
(9, '17036064-8', 'tecnico informatico', '', '', 0, 'francisco', 'figueroa villagran', '[email protected]', 94494506, 'ffiguero', 'ffiguero', 'tecnico'),
(11, '14404219-0', '-', '', '', 0, 'Daniel', 'Valenzuela Gomez', '[email protected]', 85950501, 'dvalenzu', 'dvalenzu', 'tecnico'),
(12, '15177655-8', 'Ingeniero en telecomunicaciones', '', '', 0, 'Victor', 'Valderrama Vergara', '[email protected]', 93293255, 'vvalderr', 'vvalderr', 'tecnico'),
(13, '', '', '', '', 0, '', '', '', 0, 'admin', 'entidad', 'admin'),
(14, 'sssssss', '', '', '', 0, 'prueba', '', '', 0, '', '', 'tecnico'),
(15, 'ss', '', '', '', 0, 'prueba', '', '', 0, '', '', 'tecnico'),
(16, 'dddddddddd', '', '', '', 0, 'prueba', '', '', 0, '', '', 'tecnico'),
(17, 'ddddddddddd', '', '', '', 0, 'prueba', '', '', 0, '', '', 'tecnico'),
(18, 'ssssssssssddd', '', '', '', 0, 'prueba', '', '', 0, '', '', 'tecnico'),
(19, 'sszzxx', '', '', '', 0, 'prueba', '', '', 0, '', '', 'tecnico');

--
-- Restricciones para tablas volcadas
--

--
-- Filtros para la tabla `herramientas`
--
ALTER TABLE `herramientas`
  ADD CONSTRAINT `fk_herramientas_tecnicosx` FOREIGN KEY (`tecnicosx_id`) REFERENCES `tecnicosx` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;

--
-- Filtros para la tabla `orden_servicio`
--
ALTER TABLE `orden_servicio`
  ADD CONSTRAINT `fk_orden_servicio_tecnicosx1` FOREIGN KEY (`tecnicosx_id`) REFERENCES `al_sur`.`tecnicosx` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;

--
-- Filtros para la tabla `permiso`
--
ALTER TABLE `permiso`
  ADD CONSTRAINT `fk_permiso_tecnicosx1` FOREIGN KEY (`tecnicosx_id`) REFERENCES `al_sur`.`tecnicosx` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
proyecto completo
[URL="https://mega.co.nz/#!KVlmGITQ!MTFyiW61iMypIH4ceNwnliV2ProddYuAtWv3Fii gkdg"]https://mega.co.nz/#!KVlmGITQ!MTFyiW61iMypIH4ceNwnliV2ProddYuAtWv3Fii gkdg[/URL]

Etiquetas: datatables, javascript, php+archivos
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 17:53.