2

我正在处理从 Datatables 导出到 CSV,我得到所有列的未定义值。有任何想法吗?。我正在使用稳定版的 DT 和 TT。

我已经尝试过 Github (Datatables) 的夜间版本,但没有成功。

var oTable = $('#pdf2').dataTable( {
        "bJQueryUI": true,
        "bDestroy": true,
        "sPaginationType": "full_numbers",
        "sDom": '<"H"Tfr>t<"F"ip>',
        "oTableTools": {
        "sSwfPath": "../assets/swf/copy_cvs_xls_pdf.swf",   
        "aButtons": [
                        {
                            "sExtends":    "collection",
                            "sButtonText": "Guardar",
                            "aButtons":    [ "xls", {
                                                "sExtends": "pdf",
                                                "sPdfOrientation": "portrait",
                                                "sPdfMessage": "Reporte de Guías expedidas"
                                            } ]
                        }
                    ]
                },
        oLanguage: {
            "sProcessing":   "Procesando...",
            "sLengthMenu":   "Mostrar _MENU_ registros",
            "sZeroRecords":  "No se encontraron resultados",
            "sInfo":         "Mostrando desde _START_ hasta _END_ de _TOTAL_ registros",
            "sInfoEmpty":    "Mostrando desde 0 hasta 0 de 0 registros",
            "sInfoFiltered": "(filtrado de _MAX_ registros en total)",
            "sInfoPostFix":  "",
            "sSearch":       "Buscar:",
            "sUrl":          "",
            "oPaginate": {
                "sFirst":    "Primero",
                "sPrevious": "Anterior",
                "sNext":     "Siguiente",
                "sLast":     "Último"
            }
        },
        "bProcessing": true,
        "sAjaxSource": "jsondatatable2.php?id=<?php echo $currentMonth; ?>",
        "aoColumns": [
            { "mDataProp": "valida" },
            { "mDataProp": "solicitante.cedula" },
            { "mDataProp": "solicitante.nombre" },
            { "mDataProp": "transportista.cedula" },
            { "mDataProp": "transportista.nombre" },
            { "mDataProp": "transportista.destino" },
            { "mDataProp": "transportista.municipio_destino" },
            { "mDataProp": "facturas" },
            { "mDataProp": "rubros" },
            { "mDataProp": "total" }
        ]
    } );

});

我明白了:

Válida Cédula Nombre Unidad Cosecha Rubro Variedad Restante Transportado Destino Municipio Guia undefined undefined undefined undefined undefined undefined undefined undefined undefined undefined undefined undefined

返回的 JSON:

{
    "aaData": [
        {
            "token": "f4055795d71c4f1319e3fb28851973ae",
            "valida": "24-10-2011",
            "solicitante": {
                "cedula": "12989736",
                "nombre": "Jose Medina"
            },
            "transportista": {
                "cedula": "V12220587",
                "nombre": "Victor Sanchez",
                "destino": "Bolivar",
                "municipio_destino": "Piar (Upata)"
            },
            "facturas": [
                "12444",
                "12335"
            ],
            "rubros": [
                " Antuarios, 200",
                " Eucalipto, 300"
            ],
            "total": 500
        }
    ]
}
4

0 回答 0