-2

I have relation data which is in record form:

Record : { Id: 40, Material: test, Size: test, Description: test, Quantity: test, Spec: test, Price:
test, Delivery: test, Quotes_fk: 21},
Record : { Id: 43, Material: test 2, Size: test 2, Description:
test 2, Quantity: test2, Spec: test2, Price: test2, Delivery: test2, Quotes_fk: 21}

I need to present this as a table on a pdf with the headings Id,Material,Size, Description, Quantity, Spec, Price, Delivery and as I am new to coding can’t work it out. I have managed to use Regex format to make it presentable, but it needs to be in table format. So far I can change the data to a string them replace some of the commas with line breaks.

var quotes = questionnaire.QuoteItems;
var quotes2 = quotes.toString();
var quotes3 = quotes2.replace(/{/g , "<br>");
ldz
  • 2,217
  • 16
  • 21
hsmalc
  • 1
  • 4
  • Are you not using their prebuilt table widget? That would be your simplest way especially since you are new to coding. – Markus Malessa Sep 11 '19 at 22:17
  • I can get the table to work with no issues it’s a great tool. I need to convert the relation data to a pdf table to send on email and that’s the issue. – hsmalc Sep 11 '19 at 22:22
  • Check the answer here, might be helpful https://stackoverflow.com/a/56328464/5983596 – Morfinismo Sep 11 '19 at 22:29
  • I would suggest rewording your question and being more specific then. Nowhere in your question did it come anywhere close to mentioning that. Also, I'm guessing you mean an HTML table that you can insert into your email, or do you mean an actual PDF as an attachment to the email? If it's an HTML table that you want to build I would suggest searching 'how to use Javascript to build an HTML table' or something similar for starters and trying some code yourself, then show us what you tried and we can provide guidance to resolve issues with your code. SO questions should include what you tried. – Markus Malessa Sep 11 '19 at 22:29
  • Very true, I should have been more specific. Very new to this format, thanks for the feedback. – hsmalc Sep 11 '19 at 22:31
  • So far I can change the data to a string and replace some commas with line breaks: var quotes = questionnaire.QuoteItems; var quotes2 = quotes.toString(); var quotes3 = quotes2.replace(/{/g , "
    ");
    – hsmalc Sep 11 '19 at 22:38
  • Try something like [this](https://stackoverflow.com/a/56479763/) – TheMaster Sep 11 '19 at 23:25

1 Answers1

0

Managed to work through each item in the related record and display using the following code:

for (var i=0; i < questionnaire.QuoteItems.length; i++) {

rows.push([questionnaire.QuoteItems[i].Material, questionnaire.QuoteItems[i].Size, questionnaire.QuoteItems[i].Description, questionnaire.QuoteItems[i].Quantity, questionnaire.QuoteItems[i].Spec, questionnaire.QuoteItems[i].Price, questionnaire.QuoteItems[i].Delivery]);

}
hsmalc
  • 1
  • 4