日期:2014-05-17 浏览次数:20524 次
//全选/取消全选
private void SelectedAllCheckBox(bool ischeck)
{
foreach(Control ctl in this.Controls)
{
if(ctl is CheckBox)
{
((CheckBox)ctl).Checked = ischeck;
}
}
}
//反选
private void SelectedCheckBox()
{
foreach(Control ctl in this.Controls)
{
if(ctl is CheckBox)
{
((CheckBox)ctl).Checked = !((CheckBox)ctl).Checked;
}
}
}
------解决方案--------------------
参考:
http://www.cnblogs.com/insus/archive/2011/06/17/2081639.html
http://images.cnblogs.com/cnblogs_com/insus/cbl_check_all.JPG
------解决方案--------------------
给一级菜单绑定一个name属性(name="CG"),然后给下面的子项都绑定一个tag属性(tag="CG"),
$("[name='CG']").Bind("click",function(){
$("[tag='CG']").attr("checked",$(this).attr("checked"));
});
------解决方案--------------------
如果那些复选框的项都是固定的,可以考虑简捷的table布局
------解决方案--------------------
function SelectAllCheckboxes(spanChk)
{
var oItem = spanChk.children;
var theBox=(spanChk.type=="checkbox")?spanChk:spanChk.children.item[0];
xState=theBox.checked;
elm=theBox.form.elements;
for(i=0;i<elm.length;i++)
if(elm[i].type=="checkbox" && elm[i].id!=theBox.id)
{
if(elm[i].checked!=xState)
elm[i].click();
}
}
------解决方案--------------------
<div style="font-size:12px;">
<table>
<tr>
<td align="left">采购权限<input type="checkbox" id="cbSelAll" onclick="cbClick(this.id,'caigou');" /></td>
</tr>
<tr>
<td>新增采购订单<input type="checkbox" name="caigou" class="caigou" /></td>
<td>修改采购订单<input type="checkbox" name="caigou" class="caigou" /></td>
<td>删除采购订单<input type="checkbox" name="caigou" class="caigou" /></td>
</tr>
<tr>
<td colspan="3">新增退货订单<input type="checkbox" name="caigou" class="caigou" /></td>
</tr>
</table>
</div>
<hr />
<div style="font-size:12px;">
<table>
<tr>
<td align="left">销售权限<input type="checkbox" id="cbSelAll_Sale" onclick="cbClick(this.id,'sale');" /></td>
</tr>
<tr align="right">
<td>新增销售订单<input type="checkbox" name="sale" class="sale" /></td>
<td>修改销售订单<input type="checkbox" name="sale" class="sale" /></td>
<td>删除销售订单<input type="checkbox" name="sale" class="sale" /></td>
</tr>
<tr>
<td colspan="3">新增退货订单<input type="checkbox" name="sale" class="sale" /></td>
</tr>
</table>
</div>