As the title says. I am having trouble on accessing the checkbox on webgrid.
My 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>
My Jquery
<script>
$('#subjectSave').click(function mySave(e) {
var arrItem = [];
var commaSeparatedIds = "";
$("#grid input[type=checkbox]").each(function (index, val){
debugger
})
})
</script>
I'm having trouble on what to put in
$("#grid input[type=checkbox]").each(function (index, val){
I only saw a code for "li" and none for webgrid. I need to get all the values of the checked checkbox put it in array and send it to the controller so I can queried each of it.
I hope someone can help me. Im still studying java so I'm not yet familiar of other kind of things. Thank you in advance
Aucun commentaire:
Enregistrer un commentaire