Not delete

Not delete

tascatasca Posts: 5Questions: 0Answers: 0
edited June 2012 in General
Hi,

I have this code and it works for create and edit but not delete.
when I click delete nothing happens.
also does not appear the new button.
Can someone help me?

var editor;
var envelopeConf = $.fn.dataTable.Editor.display.envelope.conf;
envelopeConf.attach = 'head';
envelopeConf.windowScroll = false;

$(document).ready(function() {
editor = new $.fn.dataTable.Editor( {
"ajaxUrl": "controle/categ.php",
"domTable": "#telactg",
"display": "envelope",
"fields": [ {
"label": "Descrição:",
"name": "nome"
}, {
"label": "Calculo:",
"name": "calculo",
"type": "select",
"ipOpts": [
{ "label": "Divisão igual", "value": "IGUAL" },
{ "label": "Calculo 1", "value": "CALCULO1" },
{ "label": "Calculo 2", "value": "CALCULO2" },
{ "label": "Calculo 3", "value": "CALCULO3" },
{ "label": "Fração Ideal", "value": "FRACAO" }
],
"default": "Divisão igual"
}, {
"label": "Sinal:",
"name": "sinal",
"type": "radio",
"ipOpts": [
{ "label": "Entrada", "value": "+" },
{ "label": "Saída", "value": "-" }
],
"default": "Saída"
}
],
"events": {
"onPreSubmit": function ( o ) {
if ( o.data.nome.length < 3 ) {
this.error('Descrição da Categoria é obrigatória');
return false;
}
else if ( o.data.nome.length < 3 ) {
this.error('browser', 'The browser name length must be less that 10 characters');
return false;
}
// ... etc
}
}
} );

// New record
$('#new').click(function(e){
e.preventDefault();
editor.create(
'Nova Categoria',
{ "label": "Salvar", "fn": function () { editor.submit() } }
);
} );

// Edit record
$('#telactg').on('click', 'a.editor_edit', function (e) {
e.preventDefault();
editor.edit(
$(this).parents('tr')[0],
'Editando Categoria',
{ "label": "Salvar", "fn": function () { editor.submit() } }
);
} );


// Delete a record
$('#telactg').on('click', 'a.editor_remove', function (e) {
e.preventDefault();

editor.message( "Tem certeza que deseja excluir essa categoria?" );
editor.remove(
$(this).parents('tr')[0],
'Remover Categoria',
{ "label": "Deletar", "fn": function () { editor.submit() } }
);
} );

$('#telactg').dataTable( {
"bJQueryUI": true,
"sDom": 'T<"clear"><"H"lfr>t<"F"ip>',
"aaSortingFixed": [[ 2, "asc" ]],
"sPaginationType": "full_numbers",
"sAjaxSource": "controle/categ.php",
"oLanguage":
{
"sProcessing" : "Processando...",
"sLengthMenu" : "Mostrar _MENU_ registros",
"sZeroRecords" : "Não foram encontrados resultados",
"sInfo" : "Mostrando de _START_ até _END_ de _TOTAL_ registros",
"sInfoEmpty" : "Mostrando de 0 até 0 de 0 registros",
"sInfoFiltered" : "(filtrado de _MAX_ registros no total)",
"sInfoPostFix" : "",
"sSearch" : "Buscar:",
"sUrl" : "",
"oPaginate":
{
"sFirst" : "Primeiro",
"sPrevious" : "Anterior",
"sNext" : "Seguinte",
"sLast" : "Último"
}
},
"aoColumns": [
{ "mDataProp": "nome" },
{ "mDataProp": "calculo", "sClass": "center" },
{ "mDataProp": "sinal", "sClass": "center" },
{
"mDataProp": null,
"sClass": "center",
"sDefaultContent": ''+
''
}
]
} );
} );


and controle/categ.php

<?php

require_once '../modelo/class/DTField.class.php';
require_once '../modelo/class/DTFormat.class.php';
require_once '../modelo/class/DTValidate.class.php';
require_once '../modelo/class/DTEditor.mysql.pdo.class.php';

require_once '../modelo/db.php';
$dbz = new db();
$db = $dbz->dbx;
$editor = new DTEditor(
$db, // DB resource
'categ', // DB table
'id', // Primary key
'row_', // ID prefix to add to the TR rows (makes it valid and unique)
array( // Fields
new DTField( array(
"name" => "id",
"dbField" => "id"
) ),
new DTField( array(
"name" => "nome",
"dbField" => "nome",
"validator" => "DTValidate::required"
) ),
new DTField( array(
"name" => "sinal",
"dbField" => "sinal",
"validator" => "DTValidate::required"
) ),
new DTField( array(
"name" => "calculo",
"dbField" => "calculo",
"validator" => "DTValidate::required"
) )
)
);

// The "process" method will handle data get, create, edit and delete
// requests from the client
echo json_encode( $editor->process($_POST) );

Replies

  • allanallan Posts: 63,107Questions: 1Answers: 10,394 Site admin
    Are you getting any script errors on the Javascript console? Is the Ajax request for the delete being sent? And if so, what is coming back from the server?

    Allan (full of questions today ;-) ).
  • tascatasca Posts: 5Questions: 0Answers: 0
    Hora: 28-06-2012 12:15:04
    Erro: o.data.nome is undefined
    Arquivo-fonte: http://localhost/app/js/jquery.js
    Linha: 40
  • tascatasca Posts: 5Questions: 0Answers: 0
    and google chrome this


    66
    Uncaught TypeError: Cannot read property 'dom' of null
    e.Editor.display.envelope.d.extend._heightCalc
    e.Editor.display.envelope.d.extend._init
    f.event.dispatch jquery.js:3
    f.event.add.h.handle.i jquery.js:3
    Uncaught TypeError: Cannot read property 'length' of undefined
    $.fn.dataTable.Editor.events.onPreSubmit
    f.Editor._callbackFire
    f.Editor._submit
    f.Editor.submit
    editor.remove.fn
    f.Editor.buttons.g
    f.event.dispatch jquery.js:3
    f.event.add.h.handle.i
  • tascatasca Posts: 5Questions: 0Answers: 0
    Sorry, my error

    thanks for this work
This discussion has been closed.