Para pdfmake, tengo una tabla en la que usa dos filas por registro. Ex:
y cuando la mesa se rompe se rompe por cada fila. Sin embargo, quiero que se rompa después o antes de 2 filas en una tabla, en las que mantienes las dos filas juntas en una página.
Quiero que las dos filas estén en la misma página. ¿Hay alguna manera de asegurarse de que esto suceda? Intenté usar la función pageBreakBefore, sin embargo, no soy tan intuitivo con ella y no ha habido buenos ejemplos en línea.
var dd = { content: [ 'The following table has nothing more than a body array', { style: 'tableExample', table: { dontBreakRows:true, // headerRows:1, body: [ [{text:'Col', colSpan:3, fillColor:'grey'}, {},{}], [{text:'Column 1',fillColor:'blue'}, {text:'Column 2',fillColor:'blue'}, {text:'Column 3',fillColor:'blue'}], ['One value goes here', 'Another one here', 'OK?'], [{text:'Description:\n'+'sdfgdhfjsfgvbnfhjfhjfghjgfjgfjfhjfghjgffghjgfasfsjgkfldshgfkld',colSpan:3}], ['One value goes here', 'Another one here', 'OK?'], [{text:'Description:\n'+'sdfgdhfjsfgvbnfhjfhjfghjgfjgfjfhjfghjgffghjgfasfsjgkfldshgfkld',colSpan:3}] , ['One value goes here', 'Another one here', 'OK?'], [{text:'Description:\n'+'sdfgdhfjsfgvbnfhjfhjfghjgfjgfjfhjfghjgffghjgfasfsjgkfldshgfkld',colSpan:3}] , ['One value goes here', 'Another one here', 'OK?'], [{text:'Description:\n'+'sdfgdhfjsfgvbnfhjfhjfghjgfjgfjfhjfghjgffghjgfasfsjgkfldshgfkld',colSpan:3}] , ['One value goes here', 'Another one here', 'OK?'], [{text:'Description:\n'+'sdfgdhfjsfgvbnfhjfhjfghjgfjgfjfhjfghjgffghjgfasfsjgkfldshgfkld',colSpan:3}] , ['One value goes here', 'Another one here', 'OK?'], [{text:'Description:\n'+'sdfgdhfjsfgvbnfhjfhjfghjgfjgfjfhjfghjgffghjgfasfsjgkfldshgfkld',colSpan:3}] , ], } }, ] }Podría definir estas filas como tablas separadas, cada una en una fila en la tabla raíz. De esta manera, las filas no se separarán porque estarán en una fila en la tabla de nivel superior
Puedes manejarlo así:
pageBreakBefore: function(currentNode, followingNodesOnPage, nodesOnNextPage, previousNodesOnPage) { //Here you can change the criteria of pageBreak according to your requirement if (currentNode.id === 'myid' && (currentNode.pageNumbers.length != 1 || currentNode.pageNumbers[0] != currentNode.pages)) { return true; } //Here you can change the criteria of pageBreak according to your requirement else if (currentNode.id === 'mySecondid' && currentNode.pageNumbers.length != 1) { return true; } return false; },