Display data in an HTML Table with the DataTables plugin

0

Greetings, I am trying to fill a table using the plutables datatables, with a query from my database the method has parameters, but the display stays that way. I will add the code of the view and the action of the controller. or if they have another way of filling the table it would be very useful.

public JsonResult BuscarVentas(string f_desde, string f_hasta, string c_desde, string c_hasta, string estado, string ordenar)
    {
        var data = new List<Ventas>();
        data = objVentasBL.BuscarVentas(f_desde, f_hasta, c_desde, c_hasta, estado, ordenar);
        return Json(data, JsonRequestBehavior.AllowGet);
    }

function Buscar() {
    var f_desde = document.getElementById("fecha_desde").value;
    var f_hasta = document.getElementById("fecha_hasta").value;
    var c_desde = document.getElementById("cliente_desde").value;
    var c_hasta = document.getElementById("cliente_hasta").value;
    var estado = $("input[name='opc_estado']:checked").val();
    var ordenar = $("input[name='opc_ordenarpor']:checked").val();
    $('#reporte').DataTable({
        "bSort": false,
        "ajax": {
            "url": '@Url.Action("BuscarVentas", "Home")',
            "type": "GET",
            "data": { f_desde: f_desde, f_hasta: f_hasta, c_desde: c_desde, c_hasta: c_hasta, estado: estado, ordenar: ordenar },
            "datatype": "json"
        },
        "columns": [
                { "data": "Tipo" },
                { "data": "Numero" },
                { "data": "Serie" },
                { "data": "Codigo" },
                { "data": "Nombre" },
                { "data": "Fecha" },
                { "data": "SubtotalCero" },
                { "data": "SubtotalIva" },
                { "data": "Descuento" },
                { "data": "Iva" },
                { "data": "Neto" },
                { "data": "Estado" },
                { "data": "Operador" },
                { "data": "Obervacion" },
                { "data": "NumeroAutorizacion" }
        ],
        filter: false,
        "paging": false,
        "ordering": false,
        "info": false,
        language: {
            paginate: {
                first: "Primero",
                previous: "Anterior",
                next: "Siguiente",
                last: "Ultimo"
            }
        }
    });
}
    
asked by Ricardo España 19.04.2017 в 03:11
source

0 answers