我在if
部分写出td
条件时遇到了问题
var output = "<table id=\"report\" class=\"hover\" style=\"white-space:nowrap;\">" +
"<thead>" +
"<tr>" +
"<th>Report Date</th>" +
"<th>Group Name</th>" +
"<th>Group Status</th>" +
"<th>Plan Name</th>" +
"<th>Plan Status</th>" +
"<th>DC</th>" +
"<th>CRA</th>" +
"<th>Suspended</th>" +
"<th>Year End</th>" +
"<th>Effective</th>" +
"<th>Run Out</th>" +
"<th>Employees</th>" +
"<th>Dependents</th>" +
"</tr>" +
"</thead>" +
"<tbody>";
for (var value in (data.queryset)) {
output +=
"<tr>" +
"<td>" + data.queryset[value].generated_date + '</td>' +
'<td>' + data.queryset[value].group_name + '</td>' +
'<td>' + data.queryset[value].group_status + '</td>' +
'<td>' + data.queryset[value].plan_name + '</td>' +
'<td>' + data.queryset[value].plan_status + '</td>' +
{#'<td>' + data.queryset[value].debit_card + '</td>' +#}
'<td>' + if (data.queryset.debit_card === 1)
{None}else if (data.queryset.debit_card === 2)
{Rx } else (data.queryset.debit_card === 3)
{Full} + '</td>' +
'<td>' + data.queryset[value].cra + '</td>' +
'<td>' + data.queryset[value].claims_suspended + '</td>' +
'<td>' + data.queryset[value].year_end + '</td>' +
'<td>' + data.queryset[value].effective_date + '</td>' +
'<td>' + data.queryset[value].termination_run_out_days + '</td>' +
'<td>' + data.queryset[value].count_of_Employees + '</td>' +
'<td>' + data.queryset[value].count_of_Dependents + "</td>" +
"</tr>";
}
output += "</tbody></table>";
displayResources.html(output);
displayResources.find('#report').DataTable(options);
setTimeout(() => {
$('#main-content').show();
_this.html('Generate Report')
}, 2000);
},
error: function(error){
答案 0 :(得分:0)
请检查以下内容:
var output = "<table id=\"report\" class=\"hover\" style=\"white-space:nowrap;\">" +
"<thead>" +
"<tr>" +
"<th>Report Date</th>" +
"<th>Group Name</th>" +
"<th>Group Status</th>" +
"<th>Plan Name</th>" +
"<th>Plan Status</th>" +
"<th>DC</th>" +
"<th>CRA</th>" +
"<th>Suspended</th>" +
"<th>Year End</th>" +
"<th>Effective</th>" +
"<th>Run Out</th>" +
"<th>Employees</th>" +
"<th>Dependents</th>" +
"</tr>" +
"</thead>" +
"<tbody>";
for (var value in (data.queryset)) {
if (data.queryset.debit_card === 1){
var debt_crd = 'None';
}else if (data.queryset.debit_card === 2){
var debt_crd = 'Rx';
}else if(data.queryset.debit_card === 3){
var debt_crd = 'Full';
}
output +=
"<tr>" +
"<td>" + data.queryset[value].generated_date + '</td>' +
'<td>' + data.queryset[value].group_name + '</td>' +
'<td>' + data.queryset[value].group_status + '</td>' +
'<td>' + data.queryset[value].plan_name + '</td>' +
'<td>' + data.queryset[value].plan_status + '</td>' +
'<td>' + debt_crd + '</td>' +
'<td>' + data.queryset[value].cra + '</td>' +
'<td>' + data.queryset[value].claims_suspended + '</td>' +
'<td>' + data.queryset[value].year_end + '</td>' +
'<td>' + data.queryset[value].effective_date + '</td>' +
'<td>' + data.queryset[value].termination_run_out_days + '</td>' +
'<td>' + data.queryset[value].count_of_Employees + '</td>' +
'<td>' + data.queryset[value].count_of_Dependents + "</td>" +
"</tr>";
}
output += "</tbody></table>";
displayResources.html(output);
displayResources.find('#report').DataTable(options);
setTimeout(() => {
$('#main-content').show();
_this.html('Generate Report')
}, 2000);
},
error: function(error){