Hello,
How do I select all checkbox across all the pages on the click of a ‘check all’ checkbox in JavaScript or jQuery? Currently only the current page records get selected.
Here is my code. please give me the solution.
@model PagedList.IPagedList
@using PagedList.Mvc;
@{
ViewBag.Title = "Index";
Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}
Mobile Structure
@Html.ActionLink("Structure Number", "Index", new { sortOrder = ViewBag.StructureNumber }) | @Html.ActionLink("Structure Name", "Index", new { sortOrder = ViewBag.StructureName }) | @Html.ActionLink("Facility Code", "Index", new { sortOrder = ViewBag.ParkCode }) | @Html.ActionLink("Facility Name", "Index", new { sortOrder = ViewBag.ParkName }) | @Html.ActionLink("Update Type Code", "Index", new { sortOrder = ViewBag.UpdateTypeCode }) | @Html.ActionLink("Is Mobile Structure", "Index") | ||
|---|---|---|---|---|---|---|---|
@Html.CheckBoxFor(modelitem => item.IsSelectdRow, new { @class = "checkboxclass", @data_strno = item.StructureNumber, @id = item.Id }) | @Html.DisplayFor(modelItem => item.StructureNumber) @style1 | @Html.DisplayFor(modelItem => item.StructureName) | @Html.DisplayFor(modelItem => item.ParkCode) | @Html.DisplayFor(modelItem => item.ParkName) | @Html.DisplayFor(modelItem => item.UpdateTypeCode) | No | Yes |
Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of @Model.PageCount
@Html.PagedListPager(Model, page => Url.Action("MobileStructure", new { page, sortOrder = ViewBag.CurrentSort }))
$(document).ready(function () {
$("#tableStructures").on("click", "#ckbCheckAll", function () {
if (this.checked) {
$("#tableStructures").find('input[type="checkbox"].checkboxclass').each(function (i, k) {
$(this).prop("checked", true);
});
}
else {
$("#tableStructures").find('input[type="checkbox"]').each(function (i, k) {
$(this).prop("checked", false);
});
}
});
$("#tableStructures").on('change', "input[type='checkbox']", function () {
if ($(this).is(":checked")) {
} else {
$("#ckbCheckAll").prop("checked", false);
}
});
});
Nilesh ShahPosted Jul 12, 2019, 10:02 AM