我想询问如何隐藏一行,例如一行包含10列,第一列和第二列填充正确的值,但第三列直到结束值为空,我想隐藏具有类似条件的行。我试图在渲染之前进行过滤但不起作用,请帮忙。这是我的代码
oTable = $('#data').DataTable({
"ordering":true,
"columns": [
{data: 'no', name: 'no'},
{data: 'number', name: 'number'},
{data: 'action', name: 'action'},
{data: 'status', name: 'status'},],});
//Used For Call Data (AJAX)
<table id="data" class="table table-striped table-bordered display" style="width: 100%; overflow-x: scroll" >
<thead>
<tr>
<th style="width: 25px">No</th>
<th>No</th>
<th>Action<br></th>
<th>Current Status</th>
</tr>
//Used to make table
public function getData(Request $request)
{
return Datatables::of(\App\Model\SomeModel::query())->make(true);
}
谢谢。任何想法和帮助将非常感激
最好的方法是在PHP,ASP等后端使用。但是如果您只有一个HTML代码,则需要在所有tr标签中执行每个代码并获取要验证的元素。
例:
jQuery("#data tr").each(function(){
my_tr = jQuery(this);
my_td= my_tr.find("td.my_validate_td_class");
if(my_td.val() == ""){
my_tr.hide();
}
})