在我的MVC 5 Web App中,我使用了footable。在表格中,我有字段单选按钮,例如构建表单。
这是代码:
<thead>
<tr>
<th></th>
@foreach (var labelfreqdep in ViewBag.rbFreqDep)
{
<th style="text-align:center;" data-breakpoints="xs sm">
<label for="FrequencyID">@labelfreqdep.FrequencyDescription</label>
</th>
}
<th data-breakpoints="xs sm"></th>
</tr>
</thead>
<tbody>
<tr>
<td>First Chooses</td>
@foreach (var freqdep in ViewBag.rbFreqDep)
{
<td class="rd">
<input type="radio" name="A3_1" id="A3_1" value="@freqdep.FrequencyDescription" data-val="true" data-val-required="Please select">
</td>
}
<td class="rd">@Html.ValidationMessageFor(model => model.A3_1, "", new { @class = "text-danger" })</td>
</tr>
</tbody>
</table>
我还使用data-val =&#34; true&#34;对空字段进行验证。问题是没有显示&#34;请选择&#34;移动视图中的消息。它适用于桌面视图。当我使用加号图标展开tr时,会显示消息。我们可以在提交时展开行,以便显示消息吗?
有什么想法吗?
被修改
我用过
$("#survey_form").submit(function (event) {
$('.surveytable').footable({
"expandAll": true
});
});`
它会在提交时展开行,但不会显示验证错误
答案 0 :(得分:0)
对于有同样问题的人,我通过给按钮提供一个id来解决它,然后通过jquery处理它
<script type="text/javascript">
jQuery(function($){
$('.surveytable').footable()
$("#survey_btn").click(function (event) {
$('.surveytable').footable({
"expandAll": true
});
});
});
</script>