Printing Tabs – expand all or print all

Forums Classic DFFS Printing Tabs – expand all or print all

Viewing 1 reply thread
  • Author
    Posts
    • #19583
      Chris Diltz
      Participant

      I have a form where users need to generate a printout of all columns/values.

      Has someone come up with a way to display all tabs (I want to avoid creating a new tab with all columns) OR use a function that uses the DFFS Print Current Tab to include all tabs? Other ideas?

      Something that works in EditForm would be ideal since column descriptions need to be included (I can use the browser print function for that).

      Thanks in advance!

    • #19642
      Alexander Bautz
      Keymaster

      Hi,
      Unfortunately I haven’t had time to add more functionality to the printout of DFFS. You can use this snippet to get started on your own print function:

      function printCustomFields(){
          var pFields = ["Title","DateColumn1","Boolean2"], fieldData = getListFields(), b = [], css = [], printWindow;
          css.push("<style>");
          css.push(".print_table{width:800px;}");
          css.push(".print_header{font-size:1.5em;padding:5px;background-color:#0078d7;color:#ffffff;}");
          css.push(".printout_tr td{vertical-align:top;border-bottom:1px #c0c0c0 solid;}");
          css.push(".field_label{font-size:1.1em;padding-right:10px;}");
          css.push(".field_body{font-size:1em;}");
          css.push(".field_description{font-size:0.8em;color:#c3c3c3;}")
          css.push("<\/style>");
          b.push("<div class='print_header'>This is a custom printout of selected fields</div>");
          b.push("<table class='print_table' cellpadding='3' cellspacing='0'>")
          jQuery.each(pFields,function(i,fin){
              b.push("<tr class='printout_tr'>");
                  b.push("<td class='field_label'>"+fieldData[fin].disp + "</td>");
                  b.push("<td class='field_body'>"+getFieldValue(fin)+"<div class='field_description'>" + fieldData[fin].description + "</div></td>");
              b.push("</tr>");
          });
          b.push("</table>");
          printWindow = window.open("","PrintWindow", "width=720,height=850");
          printWindow.document.write(css.join("")+b.join(""));
      }
      printCustomFields();
      
      function getListFields() {
          var xmlWrap, result;
          xmlWrap = [];
          xmlWrap.push("<?xml version='1.0' encoding='utf-8'?>");
          xmlWrap.push("<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>");
          xmlWrap.push("<soap:Body>");
          xmlWrap.push('<GetList xmlns="http://schemas.microsoft.com/sharepoint/soap/">');
          xmlWrap.push('<listName>' + _spPageContextInfo.pageListId + '</listName>');
          xmlWrap.push('</GetList>');
          xmlWrap.push("</soap:Body>");
          xmlWrap.push("</soap:Envelope>");
          result = {};
          jQuery.ajax({
              "async": false,
              "type": "POST",
              "url":_spPageContextInfo.webServerRelativeUrl + '/_vti_bin/lists.asmx',
              "contentType": "text/xml; charset=utf-8",
              "processData": false,
              "data": xmlWrap.join(""),
              "dataType": "xml",
              "beforeSend": function (xhr) {
                  xhr.setRequestHeader('SOAPAction', 'http://schemas.microsoft.com/sharepoint/soap/GetList');
              },
              "success": function (data) {
                  jQuery('Field', data).each(function (i) {
                      result[jQuery(this).attr('Name')] = {"fin":jQuery(this).attr("Name"), "disp":jQuery(this).attr("DisplayName"), "description":jQuery(this).attr('Description') !== undefined ? jQuery(this).attr('Description') : ""};
                  });
              }
          });
          return result;
      }

      Change the “pFields” array to match the fields you like to print.

      It can be used in both NewForm, EditForm and DispForm.

      Alexander

Viewing 1 reply thread
  • You must be logged in to reply to this topic.