JSON alert(data[1]) ERROR
JSON alert(data[1]) ERROR
Good afternoon I need to print the id_dispositivo to be able to delete or edit a record
what i use is sqlserver, asp vb
regards
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="grid5.aspx.vb" Inherits="diseño_interfazes.grid5" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="estilos/datatables.css" rel="stylesheet" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.css">
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" OnSelectedIndexChanged = "OnSelectedIndexChanged" runat="server" AutoGenerateColumns="False" CssClass="footable" >
<Columns>
<asp:CommandField ShowSelectButton="True" ButtonType="Button" HeaderText="Seleccionar" >
<ControlStyle CssClass="btn btn-primary" />
</asp:CommandField>
<%-- <asp:CommandField ShowSelectButton="True" />--%>
<asp:BoundField DataField="id_dispositivo" HeaderText="Id" SortExpression="id_dispositivo" InsertVisible="False" ReadOnly="True" />
<asp:BoundField DataField="nombre_dispositivo" HeaderText="Nombre Dispositivo" SortExpression="nombre_dispositivo" />
<asp:BoundField DataField="no_serie" HeaderText="Serie" SortExpression="no_serie" />
<asp:BoundField DataField="Descripcion" HeaderText="Descripcion" SortExpression="Descripcion" />
<asp:BoundField DataField="area_trabajo" HeaderText="Area de Trabajo" SortExpression="area_trabajo" />
<asp:BoundField DataField="Departamento" HeaderText="Departamento" SortExpression="Departamento" />
<asp:BoundField DataField="Locacion" HeaderText="Locacion" SortExpression="Locacion" />
</Columns>
</asp:GridView>
<link href="estilos/CrearActividad.css" rel="stylesheet" />
<%-- <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:beatectraConnectionString %>" SelectCommand="SELECT [id_dispositivo], [nombre_dispositivo], [no_serie], [Descripcion], [area_trabajo], [Departamento], [Locacion] FROM [Dispositivos]"></asp:SqlDataSource>--%>
<br />
<u>Selected Row Values: </u>
<br />
<br />
<asp:Label ID="lblValues" runat="server" Text=""></asp:Label>
</div>
<asp:TextBox ID="txt_su_uuid" runat="server"></asp:TextBox>
<script>
$(function () {
test();
/* _showUsers();
});
//$(function () {
// _showUsers();
function _showUsers() {
// test();
dtDispositivos();
}//showUsers
function dtDispositivos() {*/
$('[id*=GridView1]').prepend($("<thead></thead>").append($(this).find("tr:first"))).DataTable({
"ajax": {
"type": "POST",
"contentType": "application/json; charset=utf-8",
"dataType": "json",
"url": 'grid5.aspx/GetCustomers',
"data": function (d) {
return JSON.stringify(d);
},
"dataSrc": "d.data",
},
columns: [{ "defaultContent": "<button type:'button' class='btn btn-primary'>Seleccionar</button>" },
{ "data": "id_dispositivo" },
{ "data": "nombre_dispositivo" },
{ "data": "no_serie" },
{ "data": "Descripcion" },
{ "data": "area_trabajo" },
{ "data": "Departamento" },
{ "data": "Locacion" }
],
"language": {
"sProcessing": "Procesando...",
"sLengthMenu": "Mostrar _MENU_ registros",
"sZeroRecords": "No se encontraron resultados",
"sEmptyTable": "Ningún dato disponible en esta tabla =(",
"sInfo": "Mostrando registros del _START_ al _END_ de un total de _TOTAL_ registros",
"sInfoEmpty": "Mostrando registros del 0 al 0 de un total de 0 registros",
"sInfoFiltered": "(filtrado de un total de _MAX_ registros)",
"sInfoPostFix": "",
"sSearch": "Buscar:",
"sUrl": "",
"sInfoThousands": ",",
"sLoadingRecords": "Cargando...",
"oPaginate": {
"sFirst": "Primero",
"sLast": "Último",
"sNext": "Siguiente",
"sPrevious": "Anterior"
},
"oAria": {
"sSortAscending": ": Activar para ordenar la columna de manera ascendente",
"sSortDescending": ": Activar para ordenar la columna de manera descendente"
},
"buttons": {
"copy": "Copiar",
"colvis": "Visibilidad"
}
},
// rowId: 'id_dispositivo',
responsive: true,
sPaginationType: "full_numbers",
stateSave: true,
});//Funcion datatable
$('#GridView1 thead tr').clone(false).appendTo('#GridView1 thead');
$('#GridView1 thead tr:eq(1) th').removeClass('sorting_asc').removeClass('sorting_dec').removeClass('sorting').removeAttr('sorting').each(function (i) {
var title = $(this).text().trim();
$(this).html('<input class="form-control" type="text" placeholder="' + title + '" />');
var table = $('#GridView1').DataTable();
$('input', this).on('keyup change', function () {
if (table.column(i).search() !== this.value) {
table
.column(i)
.search(this.value)
.draw();
}
});
$('#GridView1').on('click', 'button', function () {
var data = table.row($(this).parents('tr')).data();
alert(data[1]);
});
});
function test() {
$.ajax({
type: "POST",
url: "grid5.aspx/GetCustomers",
contentType: "application/json; charset=utf-8",
dataType: "json",
}).done(function (info){
console.log(info);
});
}//function test
});
</script>
</form>
</body>
</html>
Answers
Is this using Editor? Or are you deleting/editing elsewhere?
Colin
I am using source code that I have been entering in forums, but I have not used the editor
I would suggest having a look - Editor is designed for just that,
Colin