【问题标题】:Datatables Tabletools Ajax button, how to send all rowsDatatables Tabletools Ajax按钮,如何发送所有行
【发布时间】:2013-04-18 15:51:47
【问题描述】:

我需要从特定数据表创建自定义 PDF 打印输出。

我认为使用Ajax button 我可以做到,但它只从第一页发送表格中的信息,在本例中为 20 行。

我知道我可以让表格在屏幕上显示“所有记录”,然后单击按钮,但我不太喜欢这样,因为所有数据都将在屏幕上显示(数千行)。

还有其他方法可以发送所有数据吗?

【问题讨论】:

    标签: jquery datatables tabletools


    【解决方案1】:

    我没有找到任何使用 Ajax 按钮的方法,但找到了另一种方法。 我用过:

                    "oTableTools": {
                    "sSwfPath": "<?=LOC_JQUERY?>swf/copy_csv_xls_pdf.swf?<?=rand()?>",
                    "aButtons": [
                        {
                            "sExtends": "download",
                            "sButtonText": "Listagens PDF",
                            "sUrl": "<?=CAMINHO?>_exporta.php",
                            "sAction": "text",
                            "sTag": "default",
                            "sFieldBoundary": "",
                            "sFieldSeperator": "\t",
                            "sNewLine": "<br>",
                            "sToolTip": "Listagens",
                            "sButtonClass": "DTTT_button_text",
                            "sButtonClassHover": "DTTT_button_text_hover",
                            "mColumns": "all",
                            "bHeader": true,
                            "bFooter": true,
                            "sDiv": "",
                            "fnMouseover": null,
                            "fnMouseout": null,
                            "fnClick": function( nButton, oConfig ) {
                                var oParams = this.s.dt.oApi._fnAjaxParameters( this.s.dt );
                                var aoPost = [
    
                                    { "name": "cobranca", "value": $("select#cobranca option:selected").val() },
                                    { "name": "activo", "value": $("select#activo option:selected").val() },
                                    { "name": "id_empresa", "value": $("select#id_empresa option:selected").val() },
    
                                    { "name": "socio_numero", "value": $("#socio_numero").val() },
                                    { "name": "socio_nome", "value": $("#socio_nome").val() },
                                    { "name": "data1", "value": $("#data1").val() },
                                    { "name": "data2", "value": $("#data2").val() },
                                    { "name": "idade1", "value": $("#idade1").val() },
                                    { "name": "idade2", "value": $("#idade2").val() },
                                    { "name": "empresa_profissao", "value": $("#empresa_profissao").val() },
    
                                ];
                                var aoGet = [];
    
                                /* Create an IFrame to do the request */
                                nIFrame = document.createElement('iframe');
                                nIFrame.setAttribute( 'id', 'RemotingIFrame' );
                                nIFrame.style.border='0px';
                                nIFrame.style.width='0px';
                                nIFrame.style.height='0px';
    
                                document.body.appendChild( nIFrame );
                                var nContentWindow = nIFrame.contentWindow;
                                nContentWindow.document.open();
                                nContentWindow.document.close();
    
                                var nForm = nContentWindow.document.createElement( 'form' );
                                nForm.setAttribute( 'method', 'post' );
    
                                /* Add POST data */
                                for ( var i=0 ; i<aoPost.length ; i++ )
                                {
                                    nInput = nContentWindow.document.createElement( 'input' );
                                    nInput.setAttribute( 'name', aoPost[i].name );
                                    nInput.setAttribute( 'type', 'text' );
                                    nInput.value = aoPost[i].value;
    
                                    nForm.appendChild( nInput );
                                }
    
                                /* Add GET data to the URL */
                                var sUrlAddition = '';
                                for ( var i=0 ; i<aoGet.length ; i++ )
                                {
                                    sUrlAddition += aoGet[i].name+'='+aoGet[i].value+'&';
                                }
    
                                nForm.setAttribute( 'action', oConfig.sUrl );
    
                                /* Add the form and the iframe */
                                nContentWindow.document.body.appendChild( nForm );
    
                                /* Send the request */
                                nForm.submit();
                            },
                            "fnSelect": null,
                            "fnComplete": null,
                            "fnInit": null
    
                        },                  
                    ]
                }
    

    希望这也能帮助有需要的人。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-04
      • 2015-04-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多