如标题所述。我在访问Webgrid上的复选框时遇到问题。
我的Webgrid
<div id="grid" >
@grid.Table(
tableStyle: "table table-responsive table-bordered",
columns: grid.Columns(
grid.Column(format:@<text> <input type="checkbox" value="Check_@item.SubjectCode" name="ids" /></text>, header: "Check"),
grid.Column(columnName: "SubjectCode", header: "SubjectCode"),
grid.Column(columnName: "SubjectName", header: "SubjectName"),
grid.Column(columnName: "SubjectDescription", header: "SubjectDescription"),
grid.Column(columnName: "Units", header: "Units"),
grid.Column(columnName: "Schedule", header: "Schedule"),
grid.Column(columnName: "Instructor", header: "Instructor"),
grid.Column(columnName: "Room", header: "Room")
)
)
<div class="row">
<div class="col-md-6">
@grid.PagerList(mode: WebGridPagerModes.All, paginationStyle: "pagination pagination-small pagination-right")
</div>
</div>
@Html.Hidden("dir", grid.SortDirection)
@Html.Hidden("col", grid.SortColumn)
<div class="col-md-1">
<a class="btn btn-success btn-block" id="subjectSave" >Save</a>
</div>
<div class="col-md-1">
<a class="btn btn-success btn-block" href="~/Account/Home">Back</a>
</div>
</div>
</div>
我的Jquery
<script>
$('#subjectSave').click(function mySave(e) {
var arrItem = [];
var commaSeparatedIds = "";
$("#grid input[type=checkbox]").each(function (index, val){
debugger
})
})
</script>
我在放入东西时遇到麻烦
$(“#grid input [type = checkbox]”)。each(function(index,val){
我只看到“ li”的代码,没有看到webgrid的代码。 我需要获取所有选中复选框的值,并将其放入数组中,然后将其发送给控制器,以便我可以查询每个复选框。
我希望有人能帮助我。我仍在学习Java,所以我还不熟悉其他种类的东西。预先谢谢你