缺失值我有以下方式表的设计:隐藏表格单元输出使用jQuery/Handlebars.js
<tr>
<th rowspan="6" scope="row">Payment History: <br><em>(Up to 25 months)</em></th>
<td colspan="3">
<table id="paymentHistory" cellspacing="1" summary="Payment History" class="table table-sm table-bordered" >
<thead class="thead-default">
<tr>
<th style="white-space: nowrap;"></th>
<th style="white-space: nowrap;">Jan</th>
<th style="white-space: nowrap;">Feb</th>
<th style="white-space: nowrap;">Mar</th>
<th style="white-space: nowrap;">Apr</th>
<th style="white-space: nowrap;">May</th>
<th style="white-space: nowrap;">Jun</th>
<th style="white-space: nowrap;">Jul</th>
<th style="white-space: nowrap;">Aug</th>
<th style="white-space: nowrap;">Sept</th>
<th style="white-space: nowrap;">Oct</th>
<th style="white-space: nowrap;">Nov</th>
<th style="white-space: nowrap;">Dec</th>
</tr>
{{#each PaymentProfile}}
<tr>
<th rowspan="2">{{@key}}</th>
</tr>
<!--<tr>-->
<!--{{#each this}}-->
<!--<th style="white-space: nowrap;">{{months @key}}</th>-->
<!--{{/each}}-->
<!--</tr>-->
<tr>
{{#each this}}
<td style="height: 42px;">{{hideEmptyData this}}</td>
{{/each}}
</tr>
{{/each}}
</thead>
</table>
</td>
</tr>
我有一些细胞,其是空的某些行。我渲染的JSON有一些空的字段/元素,因此它们不会显示在表格中。我想隐藏那些空的单元。
我必须编写registerHelper或jquery函数吗?我会怎么做?
$("#paymentHistory > tbody > tr").each(function() {
console.log("inside table");
$td=$(this).find('td');
if($td.text() === ''){
$(this).css("display", "none");
}
// $(this).parent().hide();
});
我想上面的代码。但我无法进入功能本身。 我无法在控制台中打印“内部表格”。 有人可以建议我我做错了什么?
所以我想要做的是隐藏表格单元格是空的。例如,在2014年,所有月份的元素都是空的,所以我不想显示2014年的行; 2015年仅显示JAN到AUG的元素,因为其他人是空的。
JSON数据如下:
"PaymentProfile":{
"2015":{
"1":"9",
"2":"-",
"3":"-",
"4":"-",
"5":"-",
"6":"9",
"7":"9",
"8":"B",
"9":" ",
"10":" ",
"11":" ",
"12":" "
},
"2014":{
"1":" ",
"2":" ",
"3":" ",
"4":" ",
"5":" ",
"6":" ",
"7":" ",
"8":" ",
"9":" ",
"10":" ",
"11":" ",
"12":" "
}
},
有人能帮助我吗? Output of the above code
'{{#如果TD}}... {{/ if}个}' – awd
@awd事情是我不想因为所有的月份是空的,以显示整个2014行。 那我该怎么做? – JSnewbie
我认为这将有助于你提供数据的例子。 – 76484