Modify data DataTable

0

Good morning, see if you can help me: I have an ajax request so what:

function getData(){
            $.ajax({
                url: url_serv,
                type: 'GET',
                dataType: 'json',
                success: function(data){
                    imprimir(data);
                }

.... in print I do the following:

function imprimir(datos) {
            $('#miTable').DataTable({
                data: datos,
                columns:[
                    {  "data": "id"     },
                    {  "data": "name"   },
                    {  "data": "publish"},
                    {  "render": 
                        function ( data, type, row ) {
                            Aquí metere el boton para modificar y que invoque a Dialog.
                            ....código faltante....
                        }
                    }
                 ]
            });
        }

I have to add a sixth column that is a button to modify any of the rows, it is assumed that by pressing that button, a dialog with the aplog Dialog of JQuery and the data (The dialog I have created it). But to modify the row or data, I have to use "render" ... and then there make a put request to the server to modify it, but I'm lost in how to do it.

Can someone help me or indicate a little where to shoot?

HTML Code:

<body>
    <button id="cargar">Get JSON data</button>

<table id="miTable" width="100%"></table>
    <div id="dialog-form" title="Modificar pelicula">
        <p> Modifique los campos: </p>
        <form>
            <fieldset>
                <label for="id">ID:</label>
                <input type="text" name="id" id="id">
                <label for="name">Nombre:</label>
                <input type="text" name="name" id="name">
                <label for="publish">Publicación:</label>
                <input type="date" name="publicacion" id="publish">

            </fieldset>
        </form>
    </div>
</body>
    
asked by KikeSP 27.01.2017 в 09:48
source

1 answer

0

this is the column or the button that you need.

{"defaultContent":'<button type="button" class="editar btn btn-link" data-
toggle="modal" data-target=".bd-example-modal-lg"><i class="md md-edit"></i>
</button>'
},

it would be like that

 function imprimir(datos) {
        $('#miTable').DataTable({
            data: datos,
            columns:[
                {  "data": "id"     },
                {  "data": "name"   },
                {  "data": "publish"},
                {"defaultContent":'<button type="button" class="editar btn btn-link" data-
toggle="modal" data-target=".bd-example-modal-lg"><i class="md md-edit"></i>
</button>'
},
                }
             ]
        });
    }

I know you want to add the button. but I did not understand the rest if you can explain a little bit more clearly of what you want to do, friend could help you.

    
answered by 23.09.2017 в 10:09