How do I get the data in my controller from an edit editor?

How do I get the data in my controller from an edit editor?

MinsaMinsa Posts: 11Questions: 7Answers: 0
edited August 2021 in Editor

NOTE: The data filled in the editor comes from a stored procedure query
I need the data to manipulate it in a stored procedure

Is my code

[HttpPost]
public ActionResult ClientesNuevos()
{
var settings = Properties.Settings.Default;
using (var db = new Database(settings.DbType, settings.DbConnection))
{
var request = System.Web.HttpContext.Current.Request;

            var response = new Editor(db, "ClienteNuevo")
            .Model<ClienteNuevo>()
            .Field(new Field("Id"))
            .Field(new Field("Nombre"))
            .Field(new Field("Paterno"))
            //.ReadTable();
            .Process(request)
            .Data();

        //    DtResponse dtResponse = Editor.
            return Json(response);
        }

}

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(:last-child)'
        },
        buttons: [
            { extend: "create", editor: editor },
            { extend: "edit", editor: editor },
            { extend: "remove", editor: editor }
        ]
    });

});

This question has an accepted answers - jump to answer

Answers

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

    I think this is a duplicate of your other thread.

    Have you tried submitting the request as JSON and then parsing that on the server-side? If you don't want to use our .NET libraries, then that is how I would do it myself.

    Allan

Sign In or Register to comment.