How do I get the data that I am editing in the controller in datatable editor I am using asp.net mvc

How do I get the data that I am editing in the controller in datatable editor I am using asp.net mvc

MinsaMinsa Posts: 11Questions: 7Answers: 0

Is my code index

var editor;
var tabla;

$(document).ready(function () {
    editor = new $.fn.dataTable.Editor({

        ajax: {

        edit: {
                type: 'POST',                   
                url: '@Url.Action("ClientesNuevos", "ClientesProspectosCom")'
             }           
        },


        table: "#example",
        idSrc: 'Id',
        fields: [{
            label: "Id",
            name: "Id"
        }, {
            label: "Nombre",
            name: "Nombre"
        }, {
            label: "Paterno",
            name: "Paterno"  /// chingon este wey
        }
        ],
        formOptions: {
            inline: {
                onBlur: 'submit'
            }
        }
    });

    $('#example').on('click', 'tbody td:not(:first-child) ', function (e) {
        editor.inline(this);
    });

    tabla = $('#example').DataTable({
        bInfo: false,
        resposive: true,
        "scrollX": true,
        language: {
            "search": "Busqueda",
            "emptyTable": "No existe el registros con los criterios seleccionados",
            "sNext": "Sig",
            "sPrevious": "Ant"
        },

        dom: 'Bfrtip',
        pageLength: 10,
        columns: [
            {
                data: null,
                defaultContent: '',
                className: 'select-checkbox',
                orderable: false
            },
            { data: "Id", visible: true, orderable: true },
            { data: "Nombre", visible: true, orderable: true },
            { data: "Paterno", title: "Paternos", visible: true, orderable: true },

        ],
        order: [1, 'asc'],
        select: {
            style: 'os',
            selector: 'td:not(:first-child)'
        },
        buttons: [
            { extend: "create", editor: editor },
            { extend: "edit", editor: editor },
            { extend: "remove", editor: editor }
        ]
    });

});

//================================= Controller =============================
[HttpPost]
public ActionResult ClientesNuevos(ClienteNuevo data)
{

        var request = System.Web.HttpContext.Current.Request;
        var n = request.Params["Nombre"];
        var x = request.Form["rows[0][Nombre]"];            


    //    string JsonUsuarios = JsonConvert.SerializeObject(clientes);
        return new JsonResult() { Data = "", JsonRequestBehavior = JsonRequestBehavior.AllowGet };
    }

This question has an accepted answers - jump to answer

Answers

  • MinsaMinsa Posts: 11Questions: 7Answers: 0

    this is what returns me

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    You don't want to use our .NET libraries for Editor? In which case, probably your best option is to have the client-side submit the data as a JSON object - see the last example in ajax.data. Then you can deserialise the JSON rather than needing to parse the HTTP parameters.

    Allan

  • MinsaMinsa Posts: 11Questions: 7Answers: 0
    edited August 2021

    If it is what I want to pass the data to the controller for its manipulation of stored procedure

    Do you have more examples of sending data from the datatable editor to the controller?

    Allan
    I would really appreciate your help

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin
    Answer ✓

    Not really - all our .NET examples use our libraries. You could potentially use them just for the DtRequest object which is documented here. But I suspect you'd be better with the mechanism I suggested above.

    Allan

Sign In or Register to comment.