我的頁面中有兩個按鈕「全選」和「取消全選」。我需要選擇所有的行,當我點擊全選按鈕並保存ID列表在我的變量。點擊取消選擇按鈕時,應取消選擇所有行。我們將如何做到這一點?如何選擇jQuery數據表中的所有行
[HttpPost]
public ActionResult Action Name(pssing value)
{
DataTable dataTable = new DataTable();
// my code
var MyModel = new List<List<string>>();
foreach (var joblist in Jobs)
{
var sublist = new List<string>();
sublist.Add(checked.false);
sublist.Add(values));
sublist.Add(values));
....etc
baseModel.Add(sublist);
}
return new DataTableResult(return);
}
HTML:
<table cellpadding="0" cellspacing="0" border="0" class="display" id="AssignJobsTable" width="100%">
<thead>
<tr>
<th><input type="checkbox" id="selectall"/></th>
<th>ID</th>
etc ......
</tr>
</thead>
腳本:
$(function(){
// add multiple select/deselect functionality
$("#selectall").click(function() {
$('.case').attr('checked', this.checked);
});
// if all checkbox are selected, check the selectall checkbox
// and viceversa
$(".case").click(function(){
if($(".case").length == $(".case:checked").length) {
$("#selectall").attr("checked", "checked");
} else {
$("#selectall").removeAttr("checked");
}
});
});
當我點擊全選複選框它不能綁定值形成的控制器。
粘貼你的代碼,那會更有幫助 – 2013-03-05 06:41:16
我什麼也沒做。 – 2013-03-05 06:42:34
'我什麼都沒做.' ........什麼?我們不能爲你生產。 – Jai 2013-03-05 07:03:07