A option is to make use of the after() function. For example if you would like to add a TR-element after each tr.detailDHolder element then you can use something like:
If you want to add another row, you need to do it like this:
results.each(function(index){
var workOrderInteractions = this.children()[15].text();
workOrderInteractions = "test work order";
if(workOrderInteractions != "") {
//this.parent is the table and you append a new <tr> to it
this.parent().append("<tr style='display: block; clear: both; float: left;'><td>TEST "+ workOrderInteractions +"</td></tr>")
this.css('background-color', 'lightgreen');
}
});
If you would like to add a child element, which is basically a TD-element, to each tr.detailDHolder then you can use this.append() instead of this.parent().append().
I am able to append this inside current record, but the problem is later that I need to make colspan=10 into appended record to write other fields/information and fit them on whole record width.
I’m wondering, are you using this in the same script as the one shown in your first ‘post’? And the Selector of the Standard Script is the TR-element with the CSS class .detailDHolder. Otherwise, please share the entire JavaScript code and the entire HTML code.
But I suppose that it’s in this case probably better to open a technical support ticket on our ‘website’. Because then we can help you with all the issues you’re currently facing with the specific Print, Email or Web Template file.
Yes Marten its still the same script but i am going to extend this on additional logic.
This is current script:
// this script will be executed for each record from recordset
results.each(function(index)
{
// get hidden indicator from <TD> column
var indicator = this.children()[0].text();
// for record type D we will display records
if(indicator == "D")
{
this.children().removeClass("hideDRecord");
this.css('background-color', 'lightgreen');
var workOrderInteractions = this.children()[15].text();
workOrderInteractions = "test work order";
var extendedDetail = "";
if(workOrderInteractions != "")
{
extendedDetail += "<tr style='display: block; clear: both; float: left;'>";
extendedDetail += "<td colspan='10'>";
extendedDetail += "</br> TEST " + workOrderInteractions +" end.";
extendedDetail += "</td>";
extendedDetail += "<tr>";
//this.removeClass("hideDRecordExtended");
//extendedDetail += "</tr>";
//var currentRecord = this.parent().html();
//var test = currentRecord + extendedDetail;
this.append(extendedDetail);
}
}
// for DH record type (Detail Header)
else if(indicator == "DH")
{
// we want to extract container location for DH record
var containerLocation = this.children()[10].text().trim();
// if container location is empty
if(containerLocation.length == 0)
{
// we will add the only space
this.children()[10].html(" ");
}
this.children().removeClass("hideDHRecord");
this.css('background-color', 'lightblue');
}
// for DP record type (Detail Pricing)
else if(indicator == "DP")
{
// we want to extract some fields for DH record
var serviceDescription = this.children()[11].text().trim();
var slsUnDs = this.children()[12].text().trim();
var ratePrice = this.children()[13].text().trim();
var finalNetAmount = this.children()[14].text().trim();
if(serviceDescription.length == 0)
{
// we will add the only space
this.children()[11].html(" ");
}
if(slsUnDs.length == 0)
{
// we will add the only space
this.children()[12].html(" ");
}
if(ratePrice.length == 0)
{
// we will add the only space
this.children()[13].html(" ");
}
if(finalNetAmount.length == 0)
{
// we will add the only space
this.children()[14].html(" ");
}
this.children().removeClass("hideDPRecord");
this.css('background-color', 'lightyellow');
}
});
Yes the selector is still “.detailDHolder” because I am executing logic for each detail inside my detail table.
I just need to append new record after this element.
I suppose that you can still use this.after(); if you would like to add a new TR-element after each TR-element of your results.each(function (index) {}); code. Please remove the following CSS, because I suppose that this is the reason why you do have this as result:
It would be best that you open a technical support ticket so to have access to the Template and Datamapper and see first hand where the issue is. Could be something that we are all overlooking but kind of hard to figure this out without the complete source code.