我必须在索引视图中进行简单的搜索。 表中要搜索的数据不是网格视图,而是常规表 如何添加这样的简单搜索?
这是索引视图
中的代码 搜索<table class="table table-striped table-bordered">
<tr>
<th class="text-center">NIP</th>
<th class="text-center">Nama Pegawai</th>
<th class="text-center">Jumlah Dokumen</th>
<th></th>
</tr>
<?php foreach($models as $data): ?>
<tr>
<td><?= $data["nip"] ?></td>
<td><?= $data["nama"] ?></td>
<td align = "center"><?= $data["jumlah"] ?></td>
<td width = "200 px" align = "center"><a class = "btn btn-success" href = "./?r=arsip-sdm/detail&id=<?= $data['nip'] ?>">Detail</td>
</tr>
<?php endforeach; ?>
</table>
这是控制器
中的代码
答案 0 :(得分:0)
您可以使用单独的过滤器表单
例如:
Json::Value coord(int x, int y)
{
Json::Value result;
result["x"] = x;
result["y"] = y;
return result;
}
void make_event(Json::Value & event)
{
Json::Value & coords = event["Cords"];
coords[0] = coord(10, 20);
coords[1] = coord(70, 40);
coords[2] = coord(15, 65);
}
在视图中执行渲染部分并使用普通的'searchModel'=&gt; $ searchModel,在你的gridView配置
中你可以在这里看到一些样本
http://www.yiiframework.com/doc-2.0/guide-output-data-widgets.html
http://www.yiiframework.com/doc-2.0/guide-output-data-widgets.html#filtering-data http://www.yiiframework.com/doc-2.0/guide-output-data-widgets.html#separate-filter-form