Display number of displayed records in a pdf export

Display number of displayed records in a pdf export

Hildeb67Hildeb67 Posts: 66Questions: 19Answers: 1

How can I Display number of displayed records in a pdf export

Answers

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    edited May 2023

    Display it where - in the PDF document itself? Use a message (which can also be a function - see buttons.exportInfo()).

    Allan

  • Hildeb67Hildeb67 Posts: 66Questions: 19Answers: 1

    Sorry hier is my Code fpr pdf-print

    {extend: 'pdf',
                            text: 'Drucken',
                            title: 'Geplante Anwesenheit für '+gewähltertag+' - '+kalenderwoche,    
                            
                            customize: function ( doc ) {   
                            
                            variable_php_js();
                            
                            var now = new Date();
                            var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
                            var months = ["Januar","February","March","April","May","June","July","August","September","October","November","December"];
                            var hour=( now.getHours() < 10 ? "0" : "") + now.getHours()-12;
                            var myDate = now.getDay()+"." + (now.getMonth()+1)  + "." + now.getFullYear();// + " Time: "  +hour+ ":" + (now.getMinutes() < 10 ? "0" : "") + now.getMinutes() + ":" + (now.getSeconds() < 10 ? "0" : "") + now.getSeconds() ;
                                
                            doc.pageMargins = [50,50,30,50];//left,top,right,bottom Seitenrändereinstellung
                            doc.defaultStyle.fontSize = 10; //Schriftgröße Tabellen
                            doc.styles.tableHeader.fontSize = 10; //Schriftgröße Tabellen-Header
                            doc.styles.title.fontSize = 14; //Schriftgröße Überschrift
                            // Remove spaces around page title
                            doc.content[0].text = doc.content[0].text.trim();                       
                            doc.styles.message.alignment = "left"; // messageTop siehe unten -> Nachrichtentext liks vor Tabelle
                            doc.styles.tableFooter.alignment = "center";
                            doc.styles.tableHeader.alignment = "center";
                            
                            for (var i = 0; i < doc.content[2].table.body.length; i++) {
                                doc.content[2].table.body[i][5].alignment = 'center'; //Spalte Bus zentriert ausrichten
                                doc.content[2].table.body[i][7].alignment = 'center'; //Spalte Verköstigung mittig ausrichten
                                doc.content[2].table.body[i][8].alignment = 'center'; //Spalte Hausaufgaben mittig ausrichten
                            }
                    
                            // Create a footer
                                doc['footer']=(function(page, pages) {
                                return {
                                    columns: [
                                        //This is left column
                                        {
                                            alignment: 'left',                                      
                                            text: js_variable, 
                                            fontSize: 8
                                        },
                                        //This is middle column
                                        {
                                            alignment: 'center',
                                            text: ['Seite ', { text: page.toString() },  ' von ', { text: pages.toString() }], 
                                            fontSize: 8
                                        }, 
                                        {
                                        // This is the right column
                                            alignment: 'right',
                                            fontSize: 8,
                                            text: ['Erstellt am: ', { text: myDate.toString() }]
                                        }
                                    ],
                                    margin: [50, 0] //Linksausrichtung der Fußzeile
                                }
                                });
                           
                            },                          
                            messageTop: 'Liste der Anwesenheiten ',
                            orientation: 'portrait',                        
                            exportOptions: {                            
                                rows: function ( idx, data, node ) {                            
                                    var taggehtneu; 
                                    taggehtneu = taggeht.substring(1);                               
                                    if(data[kalenderwoche][taggehtneu] !== '00:00'){ // Nur Zeiten anzeigen die nicht 00:00 sind
                                        counter++;  
                                        return data;    
                                        } else  {                                       
                                        }
                                },      
                            orthogonal: "myExport"
                            },                      
                            messageBottom: '\n Anzahl Datensätze: '+counter,
                        }
    

    And this is what the report should look like, just with the right number of data records. How can I achieve this? Thank you and many greetings Chris

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    Use messageBottom as a function - something like:

    messageBottom: function () {
      return '\n Anzahl Datensätze: '+ table.page.info().recordsTotal;
    }
    

    Allan

  • Hildeb67Hildeb67 Posts: 66Questions: 19Answers: 1

    Thank you Allan, but only the data sets should be displayed that do not have a 00:00 asl time. Now all the records in the table are displayed. How can I implement this? Thanks

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    If you could link to the page showing the issue, I'll be able to determine how you are filtering the table for output, or perhaps you could show me your code. You would need to apply whatever filtering you have to the output for PDF. For example if it is only outputting selected rows, use:

    table.rows({selected:true}).count();
    

    Allan

  • Hildeb67Hildeb67 Posts: 66Questions: 19Answers: 1

    I don't use a filter, just hide the entries in the 'gehen' column with this code. Is this the wrong way? Is there any other way?

    exportOptions: {                            
                                rows: function ( idx, data, node ) {                            
                                    var taggehtneu; 
                                    taggehtneu = taggeht.substring(1);                               
                                    if(data[kalenderwoche][taggehtneu] !== '00:00'){ // Show only times that are not 00:00
                                        counter++;  
                                        return data;    
                                        } else  {                                       
                                        }
                                },
    

    This is the 'unfiltered' table

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    Yes, use the same logic in the rows selector:

    table.rows(function (idx, data, node) { ... }).count();
    

    Allan

Sign In or Register to comment.